Skip to main content
Tensors represent ordered collections of values and are written in the form (T1, T2, ...). They occupy multiple TVM stack entries sequentially and are serialized in the same order. For example, (int, slice) represents two values following one another. Tensors are anonymous structures and behave identically. Large tensors are impractical — use structures whenever possible.

Component access

Use tensor.{i} to access tensor components by their index:
This syntax also works for nested tensors:

Tensors as anonymous structures

The struct User below and a tensor (int, slice) have identical stack layouts and serialization rules:
Furthermore, obj.{field} is equivalent to tensor.{i}:

Destructuring assignments

The following syntax is valid:
This is a 2-component tensor (10, 20) assigned to two variables:
Tensors ("abcd", (10, 20)) and ("abcd", 10, 20) are placed identically as three stack entries containing the values "abcd" (as a slice), 10, and 20, respectively. However, Tolk treats (slice, (int, int)) and (slice, int, int) as distinct types.
A special placeholder _ can be used on the left side to discard a destructured value:

Empty tensors

Empty tensors are valid values:
This is analogous to creating an instance of an empty struct.