Re: Namespace
- Posted by DerekParnell (admin) Jun 19, 2010
- 1961 views
Hello Everybody,
Namespace, What is it? What is it used for? Where can I see examples? Where is it documented?
The namespace concept was created to get around a common problem with Eu v3.
When two independently created libraries both expose the same symbol name, how does your program, when it includes both libraries, know which name you are referring to in your code?
For example...
-- LIBRARY A -- global integer theXvalue = 'x'
-- LIBRARY B -- global sequence theXvalue = "X"
--- Your App ---- include lib_A.e include lib_B.e theXvalue = someFunc()
The problem is, when your code runs, it doesn't know which theXvalue you want to set. Is it the one in Library A or Library B?
In this situation you can use namespaces to help you tell Euphoria which to use.
--- Your App ---- include lib_A.e as libA include lib_B.e as libB libA:theXvalue = someFunc() if find(libB:theXvalue, libA:theXvalue) then ...
As you can see, you can explicitly disambiguate your code by telling Euphoria which exposed symbol you need to use.
It is documented in section "4.8.1 include" of the documentation.