Websites Navigation: Airbit | Shop | m-shell.net
Languages: EN | DE

Variables

A variable is a storage location identified by a name. Values can be assigned to (stored in) the variable, and the value can later be retrieved by the same name.

Variable (and function, class and module) identifiers are sequences of ordinary latin letters, digits, and the underscore character.

  • Identifiers must not start with a digit.
  • Identifiers are case sensitive, i.e. lowercase and uppercase variants are different.
  • Keywords (see appendix * ()) cannot be used as identifiers.
  • The maximum length of an identifier is 64 characters.
Examples for valid identifiers:

a
Z
AvogadroConstant
avogadro_constant
_4
x1

Examples for invalid identifiers:

9a // starts with a digit
end // is a keyword
This_identifier_is_too_long_to_be_accepted_as_it_is_over_64_chars

IdentifierChar := 'A' to 'Z' | 'a' to 'z' | '_' .
Identifier := IdentifierChar {IdentifierChar | Digit} .

There are three different kinds of variables:

  • Global variables belong to a module (see section * ()) and exist as long as the process containing the module exists. Global variables can only be created within the module declaring them.
  • Local variables belong to a function (see section * ()) and can only be referenced within their function. They are different from global variables with the same name, and exist as long as the function executes: they are created when the function is called, and are destroyed when the function returns. Hence, each invocation of a recursive function creates its own set of local variables. Function parameters are also local variables .
  • Class fields belong to a class instance (see section * ()) and exist as long as the class instance exists. Class fields are declared when declaring the class, and created when creating a class instance. They are different from local and global variables with the same name.
The distinction between global and local variable references in the code is made by module prefixes. See section * () for examples and an explanation.

ModulePrefix := [ModuleName | '.'] '.' .
Variable := [ModulePrefix] Identifier .
ModuleName := Identifier .


© 2004-2011 airbit AG, CH-8008 Zürich
Document AB-M-REF-887
mShell Home  > Documentation  > Manuals