Re: global procedure / function
- Posted by ghaberek (admin) Oct 05, 2015
- 1419 views
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)
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