Re: Data hiding
- Posted by Igor Kachan <kinz at pet?rlink.ru> Oct 19, 2007
- 593 views
Matt Lewis wrote: > > Igor Kachan wrote: > > > > To resolve the examples like to above one, I'd suggest some > > new parameter for the "as" metacommand - "sublibrary": > > > }}} <eucode> > include lib_a.e as sublibrary -- all globals of lib_a.e > </eucode> {{{ > > I think, we can implement some useful things using new > > parameters for old good key words 'with', 'without' and 'as'. > > For now, I do not see any need of new keywords in Euphoria. > > > > > I'd be interested in hearing from people other than us 3. :) > > > > OK, did you listen to me, may I continue ? > > It's a good idea in that it doesn't create any new keywords. My only > concern is that we're overloading the 'as' usage of include. > Obviously, you couldn't have a namespace called sublibrary. How would > you namespace something that was included as a sublibrary? > > The with/without directives are easier to add functionality to since their > next parameter defines the functionality by definition. Here, you've > changed the as keyword. It's easy enough to implement into the parser, > but I think it's not obvious that you're not just assigning a namespace. > > Maybe something like: > }}} <eucode> > include as private lib.e as lib > </eucode> {{{ > > The difference being that the placement of 'as' changes its meaning, rather > than simply what comes after. I think I like 'private' over sublibrary. > It's a bit more direct and connected with what its really doing. But > this syntax seems to stand out more to me than changing 'include' to > 'import.' Ok, I do not like very much that "sublibrary" too. Maybe just "$" is better here. Say:
include lib_a.e as $ -- we see only its own globals include lib_a.e as $A -- we see only its own globals with prefix A: include lib_a.e as $B. -- we see only its own globals with pefix B. include lib_a.e as C -- we see all its globals (current syntax) include lib_a.e as $D without EE -- we do not see just EE
The "$" sign already is reserved in Euphoria, so it can be used in other contexts with some new duty and sense. About "private" word I can say -- it is already used in Euphoria documentation for saying about the hidden *inner variables* of routines, so it seems to be not very good to tell about *global* things. Regards, Igor Kachan kinz at peterlink.ru