Re: Phix: How to Globalize(?) a Namespace Identifier

new topic     » goto parent     » topic index » view thread      » older message » newer message


The idea that someone/anyone would want to use mgr: in primary_app.exw without declaring mgr totally complexes me, and always has. When I see mgr: and the source file does not tell me where I should look, well that's just plain rude.

The use of "namespace helpers" in helpers.e so you do not have to say "as helpers" on the include likewise befuddles me and has only been added rather reluctantly, and probably has "bugs", one of which will almost certainly bite you if you try to do the first of what I am about to suggest.


include helpers.e as helpers 
include helpers.e as mgr 


include helpers.e as helpers 
include manager.e as mgr 


helpers:initiate()   -- [1] 


initiate_mgr()  -- [2] 

There are no doubt plenty of other ways, such as using routine_ids.

[1]: Uses the include-tree to resolve, assumes that helpers.e does not also contain/include skivvies:initiate()
[2]: I always have and always will maintain that is the best solution. As a bonus a simple search gets exactly what I want, rather than a list of two dozen or more to pick from.

PS: The whole point of namespaces is to resolve clashing globals. If you allow namespaces to be global then by rights you would also have to invent an entirely new mechanism to resolve clashing global namespaces.
Suppose John ships his helpful utilities library with util:init().
And then Jim also ships a library with util:init().
With "include as" being the place where util is defined, the solution for using both is trivial.
With "namespace util" in both you would require a sub-include mechanism to avoid the conflict, but it is doable.
With "global namespace util" you would have no option but to modify their sources every time they issued a new version.

new topic     » goto parent     » topic index » view thread      » older message » newer message


Quick Links

User menu

Not signed in.

Misc Menu