1. 4.0 include system question

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

new topic     » topic index » view message » categorize

2. Re: 4.0 include system question

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

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

3. Re: 4.0 include system question

Someday I shall learn to use markup!

murphy said...

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

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

4. Re: 4.0 include system question

murphy said...

Someday I shall learn to use markup!

murphy said...

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.

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

5. Re: 4.0 include system question

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

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

6. Re: 4.0 include system question

twbeaty said...
murphy said...

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

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

7. Re: 4.0 include system question

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.

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

8. Re: 4.0 include system question

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.

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

9. Re: 4.0 include system question

twbeaty said...

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.

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

10. Re: 4.0 include system question

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

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

Search



Quick Links

User menu

Not signed in.

Misc Menu