4. Object system¶
This chapter describes the object system.
4.1. Values¶
A value is a the primitive unit of data. “Value” can be abbreviated to “val.” 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 embedded properties.
4.2. Embedded properties¶
Embedded properties are any data contained in a value not via variables. The following are examples of embedded properties:
the Unicode code point sequence of a str value
the scale and the mantissa of a num value
the sequence of instructions of a fun value
Embedded properties cannot be accessed directly from Kink programs, but can be used by the runtime, or host procedures.
4.3. Variables¶
A variable is a pair of a value and a finite length sequence of Unicode code points. The set of all the variables is defined as: Variables = { (owner, symbol) | owner is a value, and symbol is a finite length sequence of Unicode code points }.
Here, owner is said to be the owner of the variable,
and symbol is said to be the symbol of the variable.
The variable is said to be a variable of owner.
If a symbol is accepted by [a-z_][a-z0-9_?]*,
the symbol is called a function symbol.
If a symbol is accepted by ([a-z_][a-z0-9_?]*)?[A-Z][a-zA-Z0-9_?]*,
the symbol is called a data symbol.
4.3.1. Variable content¶
A variable has a content. The content is either empty, or a value.
4.3.2. Variable operations¶
There are three primitive operations about variables.
Variable-load operation: Gets the content of a variable. The result is either empty or a value.
Variable-store operation: Sets a value as the content of the variable.
Variable-symbols operation: For value X, gets { symbol | the content of variable (X, symbol) is a value }.
4.3.3. Memory model¶
A variable acts like a non-volatile field of Java.