4. オブジェクトシステム

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. 変数

変数は、値と、有限長のUnicodeコードポイントの列の対である。すべての変数の集合は、次のように定義される: 変数たち = { (owner, symbol) | ownerは値、symbolは有限長のUnicodeコードポイントの列 }。

ここで、 owner は変数の所有者、 symbol は変数のシンボルと呼ばれる。この変数は、 owner の変数であると呼ばれる。

シンボルが [a-z_][a-z0-9_?]* を満たすとき、そのシンボルは関数シンボルと呼ばれる。シンボルが ([a-z_][a-z0-9_?]*)?[A-Z][a-zA-Z0-9_?]* を満たすとき、そのシンボルはデータシンボルと呼ばれる。

4.3.1. 変数の内容

変数は内容を持つ。内容は、空であるか、値であるかのどちらかである。

4.3.2. 変数操作

次に挙げる三つの根本的な変数操作がある。

  • 変数ロード操作: 変数の内容を取り出す。結果は空か、値かのいずれかである。

  • 変数格納操作: ある値を変数の内容にする。

  • 変数シンボル集合操作: 値Xについて、集合 { symbol | 変数 (X, symbol) の内容が値である } を得る。

4.3.3. Memory model

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