2.5. Object system¶
This chapter describes the object system.
2.5.1. Values¶
For example, each line of the following example produces a value.
'Foo' # a str value
42 # a num value
{(:Num) Num * 2 } # a fun value
Aside from variables, a value has intrinsic properties.
- intrinsic properties¶
Any data contained in a value not via variables.
The following are examples of intrinsic properties:
the rune sequence of a str value
the scale and the unscaled value of a num value
the sequence of instructions of a fun value
Intrinsic properties cannot be accessed directly from Kink programs, but can be used by the runtime, or host procs.
2.5.2. Variables¶
- variable¶
A pair of the owner value and the sym, defined as follows: Variables = { (owner, sym) | owner is a value, and sym is a unicode string }. Here,
owner
is said to be the owner of the variable, andsym
is said to be the symbol of the variable. The variable is said to be a variable ofowner
. Variable can be abbreviated to var.
A variable has a content, which is either empty, or a value.
2.5.2.1. Variable operations¶
There are three primitive operations about variables.
- variable load operation¶
Gets the content of a variable, which is either empty or a value.
- variable store operation¶
Sets a content value to the variable.
- var-syms operation¶
For value X, gets { sym | the content of variable (X, sym) is not empty }.
Note that you cannot delete a variable. In other words, if the content of a variable is non-empty, it does not become empty.
2.5.2.2. Memory model¶
A variable acts like a non-volatile field of Java.