Nova Ordis Generic Variable and Expression System: Difference between revisions
Line 12: | Line 12: | ||
A variable name must start with a letter and consists in letters, digits, '_' and '-', and must not belong to the set of reserved names. | A variable name must start with a letter and consists in letters, digits, '_' and '-', and must not belong to the set of reserved names. | ||
=Scopes= | |||
Once a variable is declared in a scope, it becomes visible to all enclosed scopes (scopes that have this scope as parent) but it is not visible to this scope's enclosing scopes. | |||
=Example= | =Example= |
Revision as of 03:47, 14 September 2017
Internal
Overview
The implementation of a generic variable system. Variables are scoped, typed and named placeholders for values. Variable instances can only be created by declaring them in a scope, with Scope.declare(). Once declared in a scope, the variable is available to all enclosed scopes.The same variable may be declared in more than one scope, and may have different values in different scopes.
Values are assigned to a variable with set() and retrieved with get(). The value of a variable may be null.
Variable Names
A variable name must start with a letter and consists in letters, digits, '_' and '-', and must not belong to the set of reserved names.
Scopes
Once a variable is declared in a scope, it becomes visible to all enclosed scopes (scopes that have this scope as parent) but it is not visible to this scope's enclosing scopes.
Example
Scope s = new ScopeImpl();
Variable<String> v = s.declare("color", String.class, "blue");