1. Nested/strict namespaces?
- Posted by ghaberek (admin) Apr 07, 2012
- 1273 views
I realize that by asking this, I'm scratching on the surface of object-oriented programming, but... would be at all possible to "nest" namespaces by inheriting them via public include statements? And at this point, namespaces are strictly optional - could we have an option to force namespace that requires a namespace be used to resolve an identifier? I can really see these features being useful for large-scale projects, i.e. wxEuphoria, EuGtk, etc.
Here is an example:
-- TopLevel.e namespace TopLevel public include "TopLevel/LevelTwo.e" public function SomeFunction() return 0 end function
-- TopLevel/LevelTwo.e namespace LevelTwo public function AnotherFunction() return 0 end function
-- test.ex include "TopLevel.e" object void -- works (as expected) void = TopLevel:SomeFunction() -- works (nested namespace) void = LevelTwo:AnotherFunction() -- works (but should it?) void = TopLevel:AnotherFunction() -- does not work void = TopLevel:LevelTwo:AnotherFunction()
-Greg
2. Re: Nested/strict namespaces?
- Posted by SDPringle Apr 08, 2012
- 1136 views
Are you asking about the current state of the Interpreter or have you tried this code and found that the last case doesn't resolve but you would like it to in some later version of EUPHORIA?
3. Re: Nested/strict namespaces?
- Posted by jimcbrown (admin) Apr 08, 2012
- 1148 views
And at this point, namespaces are strictly optional - could we have an option to force namespace that requires a namespace be used to resolve an identifier?
I'd like to see something like that as well.
-- works (but should it?) void = TopLevel:AnotherFunction()
That does seem odd. I wonder what the reasoning behind having this work is. If I didn't know better, I'd say it was a bug.