Re: confusion about include

new topic     » goto parent     » topic index » view thread      » older message » newer message
Jerry_Story said...

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?

Sorry, Jerry. I also meant to directly answer your questions as well.

include file1.e 

This allows access to all 'export', 'public' and 'global' symbols visible to 'file1.e'.

public include file2.e 

This allows access to all 'export', 'public' and 'global' symbols visible to 'file2.e'. It also makes visible all 'public' symbols that are visible in 'file2.e', to files that include the current file.

export include file3.e 

This is illegal and will cause a syntax error.

-- Is there such a thing as global include file4.e 

No there is not.

Jerry_Story said...

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?

Yes, simple to initially code but complex to manage.

You can still declare your symbols as 'global'. That hasn't changed.

If you want to use third party or standard libraries that are using 'public' or 'export' symbols, and use them as if these were global symbols, you need to use the 'trick' I mentioned.

Basically, create an all-inclusive file that 'public includes' all the libraries/modules you want to use, then in your applications, include your 'all' file. Note that this will not give you access to the 'export' symbols but that is a good thing as your application is not supposed to see those anyway. To force access to 'export' symbols, you still have to directly include them into your application file.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu