1. namespace coflicts: local vs private symbols
- Posted by Lewis Townsend <Keroltarr at hotmail.com> Feb 08, 2003
- 420 views
Hello Robert, all, I may be addressing an old issue here but just a thought for future releases of Eu: With the (relatively) new namespacing abilities of Euphoria you can differintiate (sp?) between conflicting global identifiers by using prefixes. I wish there were a similar way to identify local symbols in routine that has a private symbol of the same name. Here is an example program that doesnt work without renameing something. sequence x x = {0,0,0,0} procedure p () sequence x x = x + 1 ? x end procedure ? x p () ? x I would like to see: {0,0,0,0} {1,1,1,1} {0,0,0,0} I get this error: variable x has not been assigned a value I would prefer it check the local symbol for a value before returning an error. An alternate handling of this situation could require a prefix such as "local:" or something like that. Just some thoughts here folks, any comments?
2. Re: namespace coflicts: local vs private symbols
- Posted by Derek Parnell <ddparnell at bigpond.com> Feb 09, 2003
- 404 views
----- Original Message ----- From: "Al Getz" <Xaxo at aol.com> To: "EUforum" <EUforum at topica.com> Subject: RE: namespace coflicts: local vs private symbols > > Hi again Lewis, > > > Lewis Townsend wrote: > > Hello Al, > > > > sequence x > > x = {0,0,0,0} > > procedure p () > > sequence x > > x = local:x + 1 > > ? x > > end procedure > > ? x > > p () > > ? x > > > > later > > Lewis Townsend > > > > > Ahhh! That clarifies the question a bit > > But, as long as you dont mind renaming the local "x" to > "Local:x" (which doesnt seem like a bad idea really) > then you also wont mind the following solution: > > > sequence x > x = {0,0,0,0} > > function Get_x() > return x > end function > > procedure p () > sequence x > x = Get_x() + 1 > ? x > end procedure > ? x > p () > ? x > I kinda do this renaming as a naming convention of mine. ... Variables scoped to a routine begin with 'l' (local) ... Variables scoped to the file begin with 'v' (variable) ... Varaibles scoped to global begin with 'g' (global) I've been using this convention for about 15 years with some success. Thus I'd code... sequence vx vx = {0,0,0,0} function Get_x() return vx end function procedure p () sequence lx lx = Get_x() + 1 ? lx end procedure ? vx p () ? vx