Re: Best Practices

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

Merely a question:

(and I know how Java answers this)

If you don't allow globals what are variables the next level down?

In Euphoria I guess they are namespaces.

This problem is hard.

Therefore how do you do scope??

Euphoria 4.0 introduced two new scopes:

  1. public
  2. export

Basically, these allow symbols to be seen only by files that include the file where the symbol resides. A public symbol can also optionally be seen by files that include the file where the symbol resides. The public scope is expected mainly to be of interest to library developers, where it will allow them to spread their code across multiple files, but still be able to present a simple API to their users that requires only a single include statement.

In general, I recommend using the export scope if you require visibility of a symbol in another file. This requires an explicit include statement in any file that uses the symbol, making dependencies clear and easier to understand.

Euphoria namespaces are used only for resolving which symbol to use. They do not create unique scopes like, say, C++ namespaces do.

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu