Namespaces in Felix don't work as might be expected: What happens everything in a namespace is collated in order of writing, then the namespaces initialisations are executed first in order of introduction of the namespace, and then order of writing.
This is just as if all the stuff in a namespace was compacted into the first mention, and indeed that is literally how it is implemented. The 'blank' namespace is intialised first: namespace Foo { val a = 1; } namespace Foo { val b = 2; } module Foo::Bar { val c = 3; } println Foo::a; println Foo::b; println Foo::Bar::c; open Foo; println a; println b; println Bar::c; open Foo::Bar; println c; prints all zeros, because the prints are done before Foo or Bar is initialised. Well, can we do the global namespace last instead of first? The answer is no. Consider: module library { val mytrue = true; } .. We surely don't want user code executed BEFORE the library code or system variables wouldn't be initialised. But that makes namespaces useless, because the only code that can refer to variables in them is in other namespaces. No global code, because it is always before the namespace is initialised .. except for code in flx_main(). Unfortunately, gathering all the initialisations in order of writing instead seems impossible with the current front end, because they have to be bound in their scope. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language