1. Nested/strict namespaces?

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

new topic     » topic index » view message » categorize

2. Re: Nested/strict namespaces?

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?

new topic     » goto parent     » topic index » view message » categorize

3. Re: Nested/strict namespaces?

ghaberek said...

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.

ghaberek said...
-- 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.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu