RE: Named Scopes (was Re: Feature requests for Eu 2.5.)
- Posted by Al Getz <Xaxo at aol.com> Aug 20, 2003
- 660 views
Pete Lomax wrote: > > > I decided to post this separate from my reply to CC, to stop it > getting buried. > > > I do like the idea of named scopes. My view is something like: > > scope scopename > <variables, constants, routines, and include files> > end scope scopename > > <illegal to reference anything in scopename here> > > procedure xxxx() > use scopename > ... <can use items from scopename here> > end procedure > > <illegal to reference anything in scopename here> > > use scopename > .. > <can use items from scopename here> > .. > <end of file> > > scopes may optionally be global. > If the global keyword is used anywhere inside a named scope, it makes > the definition available throughout the scope (ie to any includes > inside the scope), but not global outside the scope. > > The XXX has not been declared error should probably be followed with a > message XXXX is however defined in named scope x, similar to the > namespace qualifier is required message. > > When use scopename is coded, the <toplevel> local symbols in it can be > referenced, even if it the scope is defined in another file. > > I can't see any obvious difficulty nesting scopes, of course a use > outerscope statement does not grant access to innerscope. > > It should however be possible to code > > use outerscope > use innerscope > > but only if innerscope is declared global. > > > Pete > My idea for that was something like this: --in file1.ew---------------------------------------- namespace A1 --declared just like a function name atom x --body x=1 --body end namespace --ends just like a function name namespace A2 --another namespace within same file atom x x=2 end namespace ------------------------------------------------------ --now called from file2.ew---------------------------- include file1.ew as X ? X:A1:x --prints '1' ? X:A2:x --prints '2' ------------------------------------------------------ That would solve having to use a file for every single namespace no matter how small its body is. On the other hand, having one namespace per file means it's easier to find the particular function sets because they are always in the file with the name of the set of functions. You dont have to search around though files with a 'Find in Text' dialog in order to locate your functions. You find the filename, you've pretty much found your functions. Maybe we should start a list or something and maintain it somehow? Is there some way we can do this online? Take care for now, Al