Re: confusion about include
- Posted by ne1uno Aug 07, 2010
- 1377 views
The Euphoria 4.0 documentation, under "4.8.1 include" does not clearly explain "public" and "export".
What exactly do these lines do?
include file1.e public include file2.e export include file3.e -- Is there such a thing as global include file4.e
It used to be simple. Include something and it's included for all my files. What do I gotta do to make it work like it used to?
export constant a=1 public b=1 global constant c=1
there is no global include.
a routine, constant or varb marked global will be in scope when the file it is in is included as well as any file that includes that one. but, there are advantages to only including those symbols that are actually required.
to have a routine marked export in filexyz.e in scope,
the file it is used in has to have at least an include filexyz.e
export include will also allow any files that include that second file to see export & public in the first file and then finally public include will only allow public symbols to be seen in the next level up.
That's how I've been looking at it.
a number of people, a number of times have attempted to clarify this on the forum and in the docs. I think probably a diagram would help if anyone is handy with graphviz. I do think the current docs do a decent job of explaining the differences but a few more shorter examples might help. give it a second read.
it would also help if you could set a flag to have euphoria run a quick analyze on a can't resolve symbol in scope error to suggest an include file you might try.
if you are say converting an older program to eu4 and have a bunch of symbols to resolve, you can run bin/analyze.ex and it can find some of them. eui bin/analyze.ex prog.ex
source/std.ex can also suggest include files to try in the same way as analyze.ex but I haven't kept up with the new commandline syntax required.
the latest version of the docs contains a javascript search field which should help. you will have to run off a copy of the docs yourself, the online docs are way out of date. I believe the makefiles have a single page doc target that works if you have grabed eudoc and creole from svn.
the euphoria chm from the archive can be setup with most editors to give context sensitive help from your editor.
it's harder to describe than to do.