1. Scope Problem

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

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

.\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
       ^

new topic     » topic index » view message » categorize

2. Re: Scope Problem

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.




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

new topic     » goto parent     » topic index » view message » categorize

3. Re: Scope Problem

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 message » categorize

4. Re: Scope Problem

On Fri, 22 Apr 2005 12:24:51 -0700, codepilot Gmail Account
<codepilot at gmail.com> 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? 
Bizzare but true:
include main.e as anynameyoulike

in the include file(s). Even though they are themselves included by
main.e, it will not cause a problem. You can even do this:

-- this is main.exw.
global integer k
k=99
include main.exw as main
?main:k


Euphoria spots that a file has already been loaded, and instead of
reloading it just adds a namespace tag.

Regards,
Pete

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu