Class var describes a global variable. It is a subclass of class function, which implies that a variable is expanded to its value for all methods that do not explicitly accept type function or var.
PCE global variables have global existence, but may have local binding. The most well known var objects are @receiver, @event and @arg1 ... @arg10.
A variable has a var<-_type to define
legal values, a var<-_name to identify
them (named var objects
are used by class handle
and class spatial)
and a var<-_value. Note that these names
start with an underscore. Thus,
get(Var, '_name', Name)
yields the name of the var object, while
get(Var, name, Name)
yields the name of the var<-_value of
the var object.
Values are assigned using var->assign.
Class assign defines an
executable object to assign variables.
There are some common ways to exploit var objects in applications:
new(Dev, device),
send(Chain, for_all,
and(assign(new(SubDev, var),
?(@pce, instance, device)),
message(@arg1, for_all,
message(SubDev, display, @arg1)),
message(Dev, display, SubDev)))
<-_global_value: any Initial and
global value of the var
object. The value is restored to this value on recovery from a fatal
error.
<-_name: name* Name of the var
object. All named variables are stored in the hash_table @variables. var<-convert
uses this to convert names to var
objects.
<->_type: type Allowed type for
the current var<-_value. Actually not
verified in the current implementation.
Defaults: unchecked
<-_value to the variable. The
scope of this assignment is determined by the scope argument:
frame. A
variable frame is pushed by code->forward, send_method->send
and get_method<-get
if the implementation of the method is a code
object (user-defined class).
<-_global_value.
Defaults: The default scope is local.
Defaults: # type: unchecked
In older versions of PCE @arg1,
etc. where special objects. The x,
y, etc. variables appearing in formulas for class handle
and class spatial
where other special features. In the current implementation class var
takes care of all these cases. To keep the name-as-variable
as used in formulas compatible we had to introduce the name conversion
mechanism.