A variable object describes of an instance-variable (slot, attribute) of an object. Variables are managed by classes and used (among other things) to access slots in objects.
A variable has a behaviour<-name,
which must be unique for this class and
all super-classes of this class. A variable has a variable<-type,
which defines the type of value that can be stored in the corresponding
slot. Finally, a variable defines variable<-access:
the behaviour that is associated with it.
<-access
attribute of a variable defines the side-effect-free methods that are
associated:
none No methods, only access via object <->slotget Get access, only write through object ->slotsend Send access, only read through object <-slotboth Both read and write access
If a variable requires side-effects for writing (the most common
case), it should be declared with variable<-access:
read and a send_method with the same name should be defined on the
class. This method may write the variable using object->slot.
<-object
and‘class
variable<-instance_variables’.->_check
may be used to validate the object base. Part of its job is checking the
consistency of the values of instance variables.
See also variable->send, type<-check
and type<-convert.
<-clone)
of the instance-variable relation:
<-clone_style
of the value in the slot).
.i. do not clone
the value of the slot). If however, the value is cloned as an other part
of the cloning process, make the new field point to the copy.
<-editors.
-clone_function
for properly cloning alien data.
<-device.
If a graphical is cloned it will be disconnected from it's device. If a
device is cloned however, all graphicals part of it will be cloned and
displayed on the clone.
<-access.->initial_value
and
variable->alloc_value for details.|function->initialise.
Please note that using a normal object (e.g. size(20,5))
causes the same size instances to be shared by all individuals of this
class. In most cases one should use create(size, 20,5) to
force the creation of a new instance. See also class create.
The Prolog class compiler supports this through the following construct:
variable(size, size:=new(size(20,5)), get).
If the argument is a constant, name or int, the variable->alloc_value
is set. Otherwise special precautions are required in
class<-instance
and the variable->init_function
is set.
|function]->instance_variable.
The arguments are:
<-name)
Name of the instance variable. Instance variable names are local to a
class (though instance variables of super-classes are inherited.
<-type)
The type of object that may be used to fill the instance variable (see object<->slot).
<-access)
Defines implicit side-effect free methods associated with this variable.
See variable->access.
<-summary)
Summary string used by the online documentation
<-group)
Name of the functional group this variable belongs too.
->save_in_file’:
normal Save the value according to class <-save_stylenil Save the value as if it was @nil
See also class<-save_style, object->save_in_file
and‘file
variable<-object’.
<-get
.g.
slots of type [int] are initialised to
@default. See
also variable->initial_value.<-type,
otherwise fails. For compatibility to method<-argument_type.->clone_style<-get
requires the argument vector to be empty, variable->send
requires it to have exactly one element. variable->send
type<-checkes
the argument.
See also class behaviour, object<-get_method
and‘object
object<-send_method’.
point <->x
object ->save_in_file' to determine whether or not the value of this slot should be saved in the file. The default value is normal, which implies the value is saved depending on class variable<-save_style. If this attribute is nil`,
the value is saved as if the slot contains the value @nil.