09.03.2015 Views

Unicon Language Reference Clinton L. Jeffery Shamim Mohamed ...

Unicon Language Reference Clinton L. Jeffery Shamim Mohamed ...

Unicon Language Reference Clinton L. Jeffery Shamim Mohamed ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.6 File<br />

Files are system resources corresponding to data on secondary storage, areas on users’ displays,<br />

network connections, or databases. Operations on files cause input or output side effects on the<br />

system outside of the program execution.<br />

4 Variables<br />

Variables are names for locations in memory where values can be stored. Values are stored in<br />

variables by assignment operators. A variable name begins with a letter or underscore, followed<br />

by zero or more letters, underscores, or digits. A variable name cannot be the same as one of<br />

Icon’s reserved words, nor can it be the same as one of Icon’s keywords if it follows an adjacent<br />

ampersand character. Variables can hold values of any type, and may hold different types of<br />

values at different times during program execution.<br />

There are four kinds of variables: global, local, static, and class. Global, local, and static<br />

variables are declared by introducing one of the reserved words (global, local, or static) followed by<br />

a comma-separated list of variable names. Global variables are declared outside of any procedure<br />

or method body, while local and static variables are declared at the beginning of procedure and<br />

method bodies. Local and static variable names may be followed by an assignment operator and<br />

an initial value; otherwise variables other than procedure and class names begin with the value<br />

&null.<br />

Aliasing occurs when two or more variables refer to the same value, such that operations on<br />

one variable might affect the other. Aliasing is a common source of program bugs. Variables<br />

holding integer, real, string, or cset values are never aliased, because those types are immutable.<br />

4.1 Global<br />

Global variables are visible everywhere in the program, and exist at the same location for the entire<br />

program execution. Declaring a procedure declares a global variable initialized to the procedure<br />

value that corresponds to the code for that procedure.<br />

4.2 Local<br />

Local variables exist and are visible within a single procedure or method only for the duration of a<br />

single procedure invocation, including suspensions and resumptions, until the procedure returns,<br />

fails, or is vanquished by the return or failure of an ancestor invocation while it is suspended.<br />

Undeclared variables in any scope are implicitly local, but this dangerous practice should be<br />

avoided in large programs.<br />

Variables that are declared as parameters are local variables that are preinitialized to the<br />

values of actual parameters at the time of a procedure or method invocation. The semantics of<br />

parameter passing are the same as those of assignment.<br />

3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!