[Mono-list] Re: Resource System Proposal

Robert Deviasse rdeviasse@hotmail.com
Wed, 14 Nov 2001 11:13:10 -0500


Hi Rhys,

You use:

	using I = System.I18N.GetText;

	class Hello
	{
		public static void Main()
		{
			System.Console.WriteLine(I._("Hello World!"));
		}
	}

as an example of how your framework should work. You want to
add the _ function to the Object because I._ looks ugly. If the C# 
standardization committee is anything like the C++ standardization 
committee, there's little chance that ugliness is a good enough reason for 
putting adding something into the standard, so it'll likely be an 
implementation specific extension.

Why not consider an alternative usage that can be implemented portably:
	class Hello
	{
		Delegate _ = System.I18N.GetText ;
		public static void Main()
		{
			System.Console.WriteLine(_("Hello World!"));
		}
	}

You haven't added any lines of code and it uses the GNU getText
interface.

The disadvantage of this approach is that each object needs to
add one delegate. This actually isn't much different than your
proposal to extend Object by one method.

Alternately, you can try caching your results:
	class Hello
	{
		GetTextResourceManager _ = new System.I18N.GetTextMgr ;

		public static void Main()
		{
			System.Console.WriteLine(_["Hello World!"]);
		}
	}
In this approach, all the resource loading from the assembly is
done once by the GetTextMgr class. Essentially, this code:
        Assembly assembly = Assembly.GetCallingAssembly();
        ResourceManager mgr = (ResourceManager)(managers[assembly]);
        if(mgr == null)
        {
            mgr = new ResourceManager(assembly.FullName, assembly);
            managers[assembly] = mgr;
        }
needs to be called only once per class, instead of every _()
invocation. The main problem with this approach is that it differs
from the getText standard _() syntax since it uses property array
overloading. This is actually an advantage since it's more clear
to C# developers that _ is a virtual collection object. It's not
clear to regular C# developers that the _() delegate does this.

As for the System keyword, perhaps if Portable.NET and Mono
want to share code, a new namespace should be created called
OpenSystem. Extension to standard namespaces may cause developers
to accidentally use extensions as if they were standards. Should
we really encourage this vendor lock-in tactic?

Under the OpenSystem scheme, GetText would then be refered to as.
		Delegate _ = OpenSystem.I18N.GetText ;
or
		GetTextResourceManager _ = new OpenSystem.I18N.GetTextMgr ;


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp