Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@
"group": "Fift",
"pages": [
"languages/fift/overview",
"languages/fift/types",
"languages/fift/fift-and-tvm-assembly",
"languages/fift/deep-dive",
"languages/fift/multisig",
Expand Down
45 changes: 45 additions & 0 deletions languages/fift/types.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: "Types"
sidebarTitle: "Types"
noindex: "true"
---

import { Aside } from '/snippets/aside.jsx';

The Fift stack can contain values of the following types:

| | |
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Integer` | A TVM signed 257-bit integer. |
| `Cell` | A [TVM cell](/foundations/serialization/cells) for persistent data storage on TON Blockchain. A cell consists of up to `1023` data bits and up to `4` references to other cells. |
| `Slice` | A TVM slice is a read-only view of a TVM cell that allows sequential access to the cell's data and references. A cell can be converted into a slice, extracting stored bits and references without modifying the original cell. |
| `Builder` | A TVM builder is a mutable structure used to construct a cell by adding data and references to other cells. |
| `Null` | The TVM Null type has exactly one value `null`. In Fift, `null` is mostly used to initialize `Box`'es, hashmaps and lists. Usually denoted by `⊥`. |
| `Tuple` | A tuple is an ordered collection of values of any of the Fift types in this list, where each value is not necessarily of the same type. Tuples can be used to represent values of arbitrary algebraic data types and Lisp-style lists. |
| `String` | An UTF-8 string. |
| `Bytes` | An arbitrary sequence of 8-bit bytes, typically used to represent binary data. |
| `WordList` | A partially created list of word references, used for creating a new `WordDef`. |
| `WordDef` | An execution token, usually representing the definition of an existing Fift word. |
| `Box` | A container occupying one stack slot, that can be used to store one value of any type. Usually used to represent variables. |
| `Atom` | A simple entity uniquely identified by its name, a string. Can be used to represent identifiers, labels, operation names, tags, and stack markers. |
| `Object` | An arbitrary C++ object of any class derived from base class `td::CntObject`. It may be used by Fift extensions to manipulate other data types and interface with other C++ libraries. |

The first six types listed above are shared with TVM; the remainder are Fift-specific.

<Aside
title="No boolean type"
>
There is no dedicated `Boolean` type. Instead, booleans are represented as integers:

- "false" is `0`, "true" is `-1`, a 257-bit integer with all bits set to `1`.
- Logical operations are performed using bitwise operations.
- In conditional execution of blocks and loops with exit conditions, any nonzero integer in the conditions is regarded as "true".
</Aside>

<Aside
title="No TVM continuation type"
>
Fift does not make use of the [TVM continuation](/tvm/continuations) type explicitly; instead, if a continuation ends up in the Fift stack, it is manipulated as a value of type `Object`.

Nevertheless, Fift has words for constructing TVM continuations. Refer to TVM continuations in the Fift Assembler page for more details.
</Aside>