Re: Namespace Proposal

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

On Saturday 23 June 2001 05:28, Igor Kachan wrote:

<snip good idea>

> I don't like the *superglobal* variant of automated
> main-fail priority.
>
> Global is global. No ?   smile

Not really - consider this:

------ file.a --------
global atom pi
 pi = 3.14159
-------------------

------- main --------
include file.a

object pi -- won't work.

function f()
sequence pi -- works.
 pi = "Apple"
return pi
end function
---------------------

Global or not, the mathmatic pi is overriden by the apple pi
in function f. 

So the apple pi is local to the function, and takes priority
over the global while we are working within that namespace.
Why should we not be able to have a pi declared in the 
main program which is local to "main", and also takes 
priority over the global? Consistency is usually good.

For clarity, perhaps it might also be good to require 
a specific declaration to prove that we knew what we 
were doing when we declared "pi" in the main file.
If our variable is declared as:

"local atom pi"  -- no conflict, takes precedence over 
global, no warning issued.
  
"atom pi" -- still takes precedence for consistency's
sake, but a warning is issued if there's a global of the 
same name.

If no global exists with the same name, then no warning, 
no problem, and this syntax wouldn't break existing code. 

Regards,
Irv

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

Search



Quick Links

User menu

Not signed in.

Misc Menu