1. tutorial // scope diagrams

Thanks to Derek Parnell for making it possible to upload images


Variable

You must first declare the variable (as atom, integer, sequence, or object ) and then assign a value. The variable is then in scope to the end of the file.

http://euphoria.derekparnell.id.au/revised-scope-png/variable-1.png

Routine

Once a routine (procedure, function, or type) is declared it is in scope for the entire file.

http://euphoria.derekparnell.id.au/revised-scope-png/routine-1.png

The routine is even in scope inside the routine itself. You can write code that is recursive, calls other routines, and even makes an endless loop like this example:

http://euphoria.derekparnell.id.au/revised-scope-png/routine-2.png

routine minispace

A routine creates is own space for scope. You can declare variables here that last just to the end of the routine.

http://euphoria.derekparnell.id.au/revised-scope-png/routine-minispace-1.png

include and export

If you include a file the identifiers at first are invisible to the including file. But, if you export (public, or global) an identifier, then it will be visible to the including file. The basic rules for variables and routines apply once again to these identifiers.

The "export space" exists only between these two files. If you want to share files between more included files you must create more export|include relationships.

http://euphoria.derekparnell.id.au/revised-scope-png/export-two-1.png

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu