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:

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, defined as follows: Variables = { (owner, sym) | owner is a value, and sym is a finite length sequence of Unicode code points }.

Here, owner is said to be the owner of the variable, and sym is said to be the symbol of the variable. The variable is said to be a variable of owner. “Variable” can be abbreviated to “var”.

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.

A variable has a content, which is either empty, or a value.

4.3.1. 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 { sym | the content of variable (X, sym) is a value }.

Note that you cannot delete a variable. In other words, if the content of a variable is a value, it does not become empty.

4.3.2. Memory model

A variable acts like a non-volatile field of Java.