Re: Why doesn't this work?

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

Hello Rob, you wrote:

<big snip>

> Whenever a file is included, the global symbols in that file
> become visible in the including file, and all the code
> that comes later (in other files).

It seems to me, that regarding to namespaces, one aspect of this hasn't
been discussed yet (unless I missed it).

Say we have the following three files:
------=-------------------------=------
-- main.exw
include inc_1.e as one
include inc_2.e as two

one:show()
two:show()
------=-------------------------=------

------=-------------------------=------
-- inc_1.e
global procedure show ()
   puts(1, "printing from 'inc_1.e'\n")
end procedure
------=-------------------------=------

------=-------------------------=------
-- inc_2.e
global procedure show ()
   puts(1, "printing from 'inc_2.e'\n")
end procedure
------=-------------------------=------

Running 'main.exw' prints:
   printing from 'inc_1.e'
   printing from 'inc_2.e'
OK.


Now we change inc_2.e ...
------=-------------------------=------
-- inc_2.e
include inc_a.e
------=-------------------------=------

... and add a file inc_a.e:
------=-------------------------=------
-- inc_a.e
global procedure show ()
   puts(1, "printing from 'inc_a.e'\n")
end procedure
------=-------------------------=------


Now running 'main.exw', I'd expect to see:
   printing from 'inc_1.e'
   printing from 'inc_a.e'

But Euphoria (interpreter 2.4 Beta) says:
   printing from 'inc_1.e'
   D:\test\main.exw:6
   show has not been declared
   two:show()
          ^

Why doesn't this work?


By changing 'main.exw', so that no namespaces are needed, of course
3 files "in a row" work fine:
------=-------------------------=------
-- main.exw
include inc_2.e

show()
------=-------------------------=------

------=-------------------------=------
-- inc_2.e
include inc_a.e
------=-------------------------=------

------=-------------------------=------
-- inc_a.e
global procedure show ()
   puts(1, "printing from 'inc_a.e'\n")
end procedure
------=-------------------------=------


Best regards,
   Juergen

-- 
 /"\  ASCII ribbon campain  |    |\      _,,,---,,_
 \ /  against HTML in       |    /,`.-'`'    -.  ;-;;,_
  X   e-mail and news,      |   |,4-  ) )-,_..;\ (  `'-'
 / \  and unneeded MIME     |  '---''(_/--'  `-'\_)

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

Search



Quick Links

User menu

Not signed in.

Misc Menu