1. ver 4.0 Name Space Question ?
- Posted by bernie Jun 21, 2009
- 968 views
If I have a bunch of public constants in a Library
and I include that library in a second library.
Is there a way to make the constants visible from the second
library without making the first libraries constants global ?
2. Re: ver 4.0 Name Space Question ?
- Posted by DerekParnell (admin) Jun 21, 2009
- 975 views
If I have a bunch of public constants in a Library
and I include that library in a second library.
Is there a way to make the constants visible from the second
library without making the first libraries constants global ?
If I understand you correctly, you have this ...
-- LIBA.e -- public integer foo
and this ...
-- LIBB.e -- include LIBA.e
and you want things that include LIBB.e to be able to see foo.
If that is the case then write LIBB.e like this ...
-- LIBB.e -- public include LIBA.e
Note that we public include a file that contains public symbols so that those symbols are made 'as if' they were public in the file that has the include.
public symbols are normally exposed for one level of include, but a public include exposes included public symbols up one more extra level.
By doing this, files that include LIBB.e will also be able to see public symbols declared in LIBA.e.
3. Re: ver 4.0 Name Space Question ?
- Posted by bernie Jun 21, 2009
- 983 views
-- LIBA.e -- public constant foo1 = 1, foo2 = 2 public function foobarr1() return 0 end function public function foobarr2() return 0 end function
and this ...
-- LIBB.e -- -- No I want to pass on just the constants not -- the public functions from LIBA.e.
4. Re: ver 4.0 Name Space Question ?
- Posted by DerekParnell (admin) Jun 21, 2009
- 980 views
-- LIBA.e -- public constant foo1 = 1, foo2 = 2 public function foobarr1() return 0 end function public function foobarr2() return 0 end function
and this ...
-- LIBB.e -- -- No I want to pass on just the constants not -- the public functions from LIBA.e.
Ok. Code like this then ...
-- LIBA.e -- public constant foo1 = 1, foo2 = 2 export function foobarr1() return 0 end function export function foobarr2() return 0 end function
and this ...
-- LIBB.e -- -- I want to pass on just the constants not -- the functions from LIBA.e. public include LIBA.e
The export scope modifier is used for this purpose. It works just like public except that these symbols are only ever passed up one level only. In other words, if a file wants to use an export symbol, that file must include it explicitly.
You still do a public include to expose the public symbols but any exported symbols are not seen by files that include LIBB.e
5. Re: ver 4.0 Name Space Question ?
- Posted by bernie Jun 21, 2009
- 996 views
-- LIBA.e -- public constant foo1 = 1, foo2 = 2 public function foobarr1() return 0 end function public function foobarr2() return 0 end function
and this ...
-- LIBB.e -- -- No I want to pass on just the constants not -- the public functions from LIBA.e.
Ok. Code like this then ...
-- LIBA.e -- public constant foo1 = 1, foo2 = 2 export function foobarr1() return 0 end function export function foobarr2() return 0 end function
and this ...
-- LIBB.e -- -- I want to pass on just the constants not -- the functions from LIBA.e. public include LIBA.e
The export scope modifier is used for this purpose. It works just like public except that these symbols are only ever passed up one level only. In other words, if a file wants to use an export symbol, that file must include it explicitly.
You still do a public include to expose the public symbols but any exported symbols are not seen by files that include LIBB.e
Thanks Derek !
Now I understand the difference between export and public.
Who is ever in charge of that Developers group had better
give you a raise for being so good at explaining.
6. Re: ver 4.0 Name Space Question ?
- Posted by jeremy (admin) Jun 21, 2009
- 967 views
- Last edited Jun 22, 2009
Thanks Derek !
Now I understand the difference between export and public.
Who is ever in charge of that Developers group had better
give you a raise for being so good at explaining.
I'll speak on behalf of the dev team, as I'm sure they will all agree... As of today, we have doubled Derek's pay.
Jeremy
7. Re: ver 4.0 Name Space Question ?
- Posted by Dan_M Jun 22, 2009
- 904 views
-- LIBA.e -- public constant foo1 = 1, foo2 = 2 public function foobarr1() return 0 end function public function foobarr2() return 0 end function
and this ...
-- LIBB.e -- -- No I want to pass on just the constants not -- the public functions from LIBA.e.
Ok. Code like this then ...
-- LIBA.e -- public constant foo1 = 1, foo2 = 2 export function foobarr1() return 0 end function export function foobarr2() return 0 end function
and this ...
-- LIBB.e -- -- I want to pass on just the constants not -- the functions from LIBA.e. public include LIBA.e
The export scope modifier is used for this purpose. It works just like public except that these symbols are only ever passed up one level only. In other words, if a file wants to use an export symbol, that file must include it explicitly.
You still do a public include to expose the public symbols but any exported symbols are not seen by files that include LIBB.e
Thanks Derek !
Now I understand the difference between export and public.
Who is ever in charge of that Developers group had better
give you a raise for being so good at explaining.
Derek's explanation should be IN the EU4 docs!
And in relation to those docs, about include,
What does "N.B." MEAN?
And since, after "An identifier marked as public or export...", an explanation for public is given, there needs to be an explantion for export also, either just before or just after the explanation for public.
Dan
8. Re: ver 4.0 Name Space Question ?
- Posted by jeremy (admin) Jun 22, 2009
- 873 views
http://openeuphoria.org/docs/eu400_0012.html#_102_scope
It could be made easier to understand.
Jeremy