Re: namespace coflicts: local vs private symbols

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

----- 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 smile
> 
> 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

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

Search



Quick Links

User menu

Not signed in.

Misc Menu