1. global procedure / function

using euphoria 3.1

when looking through libraries (for example 'get.e')

i notice that some procedures & function declarations are preceeded with GLOBAL and others are not

can anyone explain to me the difference between PROCEDURE and GLOBAL PROCEDURE?

likewise between FUNCTION and GLOBAL FUNCTION?

i understand how GLOBAL affects a variable decalration - but not a procedure or function declaration

thank you for any information you can share

new topic     » topic index » view message » categorize

2. Re: global procedure / function

eeel said...

can anyone explain to me the difference between PROCEDURE and GLOBAL PROCEDURE? likewise between FUNCTION and GLOBAL FUNCTION?

That has to do with the scope of a declaration (Variable, Function or Procedure)

Euphoria 4.0 docs said...
  • If the keyword global precedes the declaration, the scope of these identifiers extends to the whole application. They can be accessed by code anywhere in the application files.
  • If the keyword public precedes the declaration, the scope extends to any file that explicitly includes the file in which the identifier is declared, or to any file that includes a file that in turn public includes the file containing the public declaration.
  • If the keyword export precedes the declaration, the scope only extends to any file that directly includes the file in which the identifier is declared.

You can read more about this topic here.

HTH

-xecronix

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

3. Re: global procedure / function

eeel said...

using euphoria 3.1

when looking through libraries (for example 'get.e')

i notice that some procedures & function declarations are preceeded with GLOBAL and others are not

can anyone explain to me the difference between PROCEDURE and GLOBAL PROCEDURE?

likewise between FUNCTION and GLOBAL FUNCTION?

i understand how GLOBAL affects a variable decalration - but not a procedure or function declaration

thank you for any information you can share

It basically works the same with variables or routines (functions and procedures). It all has to do with the concept of Scope. (Here is the corresponding doc for 4.0: Scope)

refman said...

Symbols marked as global can be used externally. All other symbols can only be used internally within their own file. This information is helpful when maintaining or enhancing the file, or when learning how to use the file. You can make changes to the internal routines and variables, without having to examine other files, or notify other users of the include file.

If you include a file that contains routines declared with global, you can call those functions from your file because they are in the global "scope."

Anything that is in another file and not declared as global is effectively hidden from you, and only accessible from within that file, because it is only in the "scope" for that file.

-Greg

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

4. Re: global procedure / function

thank you very much - xecronix & greg

i was 'forgetting' the concept that the libraries remain separate files from my program file even when 'included' in my program file - hence the need to use something like 'GLOBAL' before a routine in any these libraries if that routine is to be accessed directly by my program file

now its all clear(er) to me - and very helpful for creating my own libraries of routines

cheerz again smile

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

Search



Quick Links

User menu

Not signed in.

Misc Menu