Re: Scope Problem

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

don cole wrote:
> 
> codepilot Gmail Account wrote:
> > 
> > You define a global type/procedure/function/constant/variable in the
> > main file, then include file(s) that define the same global. Then you
> > include a file that uses it, what namespace can you put for the main
> > file? globa:globular is globa.e, globb:globular is globb.e but nothing
> > for the main file?
> > Dan
> > 
> > }}}
<eucode>
> > <test.exw>
> > global type globular(atom a)
> > =09return a=0
> > end type
> > 
> > include globa.e as globa
> > include globb.e as globb
> > 
> > include test2.e
> > </test.exw>
> > <globa.e>
> > global type globular(atom a)
> > =09return a=1
> > end type
> > </globa.e>
> > <globb.e>
> > global type globular(atom a)
> > =09return a=10
> > end type
> > </globb.e>
> > <test.e>
> > globular test
> > </test.e>
> > </eucode>
{{{

> > .\test2.e:1
> > A namespace qualifier is needed to resolve globular.
> > globular is defined as a global symbol in:
> >     test.exw
> >     .\globa.e
> >     .\globb.e
> > 
> > globular test
> >        ^
> > 
> > 
> You've got too many globals.
> 
> }}}
<eucode>
> 
> -----------------------------------
> global.e
> 
> global integer a
> -----------------
> mainProgram.exw
> include globals.e
> 
> global integer a
> 
> --results in 'a namespace qualifier is need to define a'
> --you can define a global only once in main program and/or includes.
> 
> Don Cole 
> SF
> 

He knows. He wants a way to put a namespace on an identifier in mainProgram.exw.

My opinion in this matter is that you shouldn't have to. A variable in the
current file should be prioritized over a variable in an immediately included
file, which is prioritized over a variable in a file that is included by the
immediately included include files.

Regards, Alexander Toresson

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

Search



Quick Links

User menu

Not signed in.

Misc Menu