1. 4.0 include system question
- Posted by twbeaty Aug 15, 2008
- 936 views
Hello all.
Working on my project, I have the main file, equity.e, which includes a number of other files. Here is a look at the includes that I have.
export include eqtso.e export include eqtmsg.e export include eqtc.e
Now then, I've been trying to use export with my (formerly) global routines, but I'm running into a bit of an annoyance. eqtc.e requires routines from both eqtmsg.e and eqtso.e, but it does not see this code; in order to use it, I have to explicitly include the files again in eqtc.e. Before, when the routines in eqtc.e and eqtso.e were global, having the main file calling them was enough to get them included in the namespace.
Am I just doing things wrong, or is that how we are supposed to be doing includes now? Will the end user need to include each of these files in their project, or can they just include the main file, equity.e, which has the includes shown above? btw, my test app where these problems are cropping up is just including equity.e.
Thanks, - Travis
2. Re: 4.0 include system question
- Posted by murphy Aug 15, 2008
- 920 views
try this:
export include a.e export include b.e
Put those at the top of c.e, include c.e in your program, voila, a and b stuff should be there too.
Hope I got that right
3. Re: 4.0 include system question
- Posted by murphy Aug 15, 2008
- 932 views
Someday I shall learn to use markup!
try this:
export include a.e export include b.e
Put those at the top of c.e, include c.e in your program, voila, a and b stuff should be there too.
Hope I got that right
4. Re: 4.0 include system question
- Posted by twbeaty Aug 15, 2008
- 931 views
Someday I shall learn to use markup!
try this:
export include a.e export include b.e
Put those at the top of c.e, include c.e in your program, voila, a and b stuff should be there too.
Hope I got that right
Right, that's what I'm doing in this case. The includes which I gave in the original post are in the file which the user should include in order to use the library. The problem is, to use your example, that b.e needs functions from a.e as well, but b.e isn't seeing them.
- Travis.
5. Re: 4.0 include system question
- Posted by jeremy (admin) Aug 15, 2008
- 916 views
Travis,
When you include a file with exports, the exports are included into the current file only. This is to reduce cluttering the namespace and make programs better organized (i.e. where did function abc() come from that I am using in this file?)
So, let's say you have:
-- support.e export function supporting_func() -- mylib.e include support.e ? supporing_func() -- myprog.ex include mylib.e supporting_func() -- Error!
Now, you can solve that 1 of two ways. If your library has all sorts of unrelated helpful routines, such as the standard library ... i.e. text, search, primes, io, etc... then you can have your users do:
include support.e ? supporting_func() -- good
Now, you are developing a GUI library, IIRC, so you may want to make a generic include equity.e:
-- equity.e export include support.e export include other.e export include johndoe.e -- myprog.ex include equity.e ? supporting_func() -- Good!
The "export include" not only includes functions, but passes on the exported items from the include onto the current file's parent.
Jeremy
6. Re: 4.0 include system question
- Posted by jeremy (admin) Aug 15, 2008
- 902 views
try this:
export include a.e export include b.e
Put those at the top of c.e, include c.e in your program, voila, a and b stuff should be there too.
Right, that's what I'm doing in this case. The includes which I gave in the original post are in the file which the user should include in order to use the library. The problem is, to use your example, that b.e needs functions from a.e as well, but b.e isn't seeing them.
b.e needs to include a.e
Jeremy
7. Re: 4.0 include system question
- Posted by murphy Aug 15, 2008
- 908 views
Sorry, I didn't read your post carefully enough.
I have the same setup with EuGTK, and many routines/variables are marked export in these two files:
GtkEnums.e GtkRoutines.e
The main file: GtkEngine.e, says:
export include GtkEnums.e export include GtkRoutines.e
Now, it is only necessary for a GTK program to :
include GtkEngine.e
in order to access variables and routines in GtkEnums and GtkRoutines, as long as those routines are marked export.
Anyway, that works for me.
8. Re: 4.0 include system question
- Posted by twbeaty Aug 15, 2008
- 932 views
Okay ...
That seems to be how things are panning out. As I said, I do have the one file which the user will include, equity.e. The problem was just within the various include files that make up the library, and trying to get used to the new scheme. I think it will be fine once I get the hang of things.
- Travis.
9. Re: 4.0 include system question
- Posted by DerekParnell (admin) Aug 15, 2008
- 930 views
I think it will be fine once I get the hang of things.
The general rule is pretty simple really. If file X needs to see exported stuff that's in file Y, then X needs to include Y.
However, because some libraries are multi-file ones, the application user shouldn't need to know which particular library file the symbol comes from, just that it comes from the library. In that case, the library writer will provide a library file that simply includes all the library files that implement the library's API.
So, in you're case you are doing it right, namely that equity.e contains the lines
export include eqtso.e export include eqtmsg.e export include eqtc.e
Thus application coders just need to include equity.e. However, as the library author, if one of the library's component files needs to see things in another library component file, it needs to follow the general rule above.
In your case, as eqtc.e needs to see stuff in eqtso.e and eqtmsg.e, then eqtc.e must explicitly include both those files.
10. Re: 4.0 include system question
- Posted by ChrisB (moderator) Aug 16, 2008
- 926 views
Hi
Just reading the include documentation. Does Eu 4.0 still have support for the euinc.conf file, if so it isn't mentioned in the docs.
Chris