> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ton.org/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.ton.org/feedback

```json
{
  "path": "/tolk/from-func/stdlib-comparison",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# Standard libraries comparison

Tolk provides a standard library that evolved from [FunC's standard library](/languages/func/stdlib).
Therefore, many functions from `stdlib.fc` can be mapped to Tolk, and most of these functions were converted into [methods](/languages/tolk/syntax/functions-methods).

## Functions vs methods

Tolk supports [declaring methods](/languages/tolk/syntax/functions-methods), including primitives. Consequently, many FunC global-scope functions are now methods, e.g., `cell.hash()`, `tuple.size()`, etc.

```tolk theme={"theme":{"light":"github-light-default","dark":"dark-plus"},"languages":{"custom":["/resources/grammars/tolk.tmLanguage.json","/resources/grammars/tlb.tmLanguage.json","/resources/grammars/fift.tmLanguage.json","/resources/grammars/tasm.tmLanguage.json","/resources/grammars/func.tmLanguage.json"]}}
@pure
fun cell.hash(self): uint256
    asm "HASHCU"
```

In FunC, `x.f()` works equally to `f(x)`. For instance, `someTuple.tuple_size()` and `tuple_size(someTuple)`. In Tolk, `someTuple.size()` is the only valid notation.

## Renamed and removed functions

For `load_xxx`, `store_xxx`, and `skip_xxx`, use [automatic serialization](/languages/tolk/features/auto-serialization). Methods `slice.loadXXX`, `builder.storeXXX`, and `slice.skipXXX` are available for manual cell parsing, but their use is not recommended.

For `idict_xxx`, `udict_xxx`, and `dict_xxx`, use [native maps](/languages/tolk/types/maps). Dictionaries remain available in the file `@stdlib/tvm-dicts`, but their is not recommended.

Other functions:

| FunC name                     | Tolk name                            |
| ----------------------------- | ------------------------------------ |
| `empty_tuple`                 | `[]` (creates `array<unknown>`)      |
| `t~tpush(v)`                  | `t.push(v)`                          |
| `first(t)` or `t.first()`     | `t.first()`                          |
| `at(t,i)` or `t.at(i)`        | `t.get(i)`                           |
| `touch(v)`                    | `v.stackMoveToTop()`                 |
| `impure_touch`                | *(deleted)*                          |
| `single`                      | *(deleted)*                          |
| `unsingle`                    | *(deleted)*                          |
| `pair`                        | *(deleted)*                          |
| `unpair`                      | *(deleted)*                          |
| `triple`                      | *(deleted)*                          |
| `untriple`                    | *(deleted)*                          |
| `tuple4`                      | *(deleted)*                          |
| `untuple4`                    | *(deleted)*                          |
| `second`                      | *(deleted)*                          |
| `third`                       | *(deleted)*                          |
| `fourth`                      | *(deleted)*                          |
| `pair_first`                  | *(deleted)*                          |
| `pair_second`                 | *(deleted)*                          |
| `triple_first`                | *(deleted)*                          |
| `triple_second`               | *(deleted)*                          |
| `triple_third`                | *(deleted)*                          |
| `minmax`                      | `minMax`                             |
| `now`                         | `blockchain.now`                     |
| `my_address`                  | `contract.getAddress`                |
| `get_balance + pair_first`    | `contract.getOriginalBalance`        |
| `cur_lt`                      | `blockchain.logicalTime`             |
| `block_lt`                    | `blockchain.currentBlockLogicalTime` |
| `cell_hash(c)`                | `c.hash()`                           |
| `slice_hash(s)`               | `s.hash()`                           |
| `string_hash(s)`              | `s.bitsHash()`                       |
| `check_signature`             | `isSignatureValid`                   |
| `check_data_signature`        | `isSliceSignatureValid`              |
| `compute_data_size(c)`        | `c.calculateSizeStrict()`            |
| `slice_compute_data_size(s)`  | `s.calculateSizeStrict()`            |
| `compute_data_size?(c)`       | `c.calculateSize()`                  |
| `slice_compute_data_size?(s)` | `s.calculateSize()`                  |
| `~dump`                       | `debug.print`                        |
| `~strdump`                    | `debug.printString`                  |
| `dump_stack`                  | `debug.dumpStack`                    |
| `get_data`                    | `contract.getData`                   |
| `set_data`                    | `contract.setData`                   |
| `get_c3`                      | `getTvmRegisterC3`                   |
| `set_c3`                      | `setTvmRegisterC3`                   |
| `bless`                       | `transformSliceToContinuation`       |
| `accept_message`              | `acceptExternalMessage`              |
| `set_gas_limit`               | `setGasLimit`                        |
| `buy_gas`                     | *(deleted)*                          |
| `commit`                      | `commitContractDataAndActions`       |
| `divmod`                      | `divMod`                             |
| `moddiv`                      | `modDiv`                             |
| `muldiv`                      | `mulDivFloor`                        |
| `muldivr`                     | `mulDivRound`                        |
| `muldivc`                     | `mulDivCeil`                         |
| `muldivmod`                   | `mulDivMod`                          |
| `begin_parse`                 | `beginParse`                         |
| `end_parse(s)`                | `s.assertEnd()`                      |
| `first_bits(s)`               | `s.getFirstBits()`                   |
| `skip_last_bits(s)`           | `s.removeLastBits()`                 |
| `slice_last(s)`               | `s.getLastBits()`                    |
| `cell_depth(c)`               | `c.depth()`                          |
| `slice_refs(s)`               | `s.remainingRefsCount()`             |
| `slice_bits(s)`               | `s.remainingBitsCount()`             |
| `slice_bits_refs(s)`          | `s.remainingBitsAndRefsCount()`      |
| `slice_empty?(s)`             | `s.isEmpty()`                        |
| `slice_data_empty?(s)`        | `s.isEndOfBits()`                    |
| `slice_refs_empty?(s)`        | `s.isEndOfRefs()`                    |
| `slice_depth(s)`              | `s.depth()`                          |
| `equal_slice_bits(a,b)`       | `a.bitsEqual(b)`                     |
| `builder_refs(b)`             | `b.refsCount()`                      |
| `builder_bits(b)`             | `b.bitsCount()`                      |
| `builder_depth(b)`            | `b.depth()`                          |
| `begin_cell`                  | `beginCell`                          |
| `end_cell`                    | `endCell`                            |
| `parse_addr`                  | *(deleted)*                          |
| `parse_std_addr`              | use `address` type                   |
| `parse_var_addr`              | *(deleted)*                          |
| `config_param`                | `blockchain.configParam`             |
| `raw_reserve`                 | `reserveToncoinsOnBalance`           |
| `raw_reserve_extra`           | `reserveExtraCurrenciesOnBalance`    |
| `send_raw_message`            | use `createMessage`                  |
| `set_code`                    | `contract.setCodePostponed`          |
| `random`                      | `random.uint256`                     |
| `rand`                        | `random.range`                       |
| `get_seed`                    | `random.getSeed`                     |
| `set_seed`                    | `random.setSeed`                     |
| `randomize`                   | `random.initializeBy`                |
| `randomize_lt`                | `random.initialize`                  |
| `dump`                        | `debug.print`                        |
| `strdump`                     | `debug.printString`                  |
| `dump_stk`                    | `debug.dumpStack`                    |
| `empty_list`                  | `lisp_list<T> []`                    |
| `cons`                        | `list.prependHead(v)`                |
| `uncons`                      | `list.getHead()`, `list.getTail()`   |
| `car`                         | `list.getHead()`                     |
| `cdr`                         | `list.getTail()`                     |
| `new_dict`                    | `map<K, V> []`                       |
| `dict_empty?(d)`              | `m.isEmpty`                          |
| `pfxdict_get?`                | `prefixDictGet`                      |
| `pfxdict_set?`                | `prefixDictSet`                      |
| `pfxdict_delete?`             | `prefixDictDelete`                   |

Lisp-style lists require an explicit import; IDEs usually add the import automatically.

```tolk theme={"theme":{"light":"github-light-default","dark":"dark-plus"},"languages":{"custom":["/resources/grammars/tolk.tmLanguage.json","/resources/grammars/tlb.tmLanguage.json","/resources/grammars/fift.tmLanguage.json","/resources/grammars/tasm.tmLanguage.json","/resources/grammars/func.tmLanguage.json"]}}
import "@stdlib/lisp-lists"
```

## Mutating functions

In FunC, `x~method` mutates, whereas `x.method` returns a copy. In Tolk, methods are called with dot `.` and may [mutate](/languages/tolk/syntax/mutability) the object.

| FunC                               | Tolk                                      |
| ---------------------------------- | ----------------------------------------- |
| `int n = cs~load_uint(32);`        | `var n = cs.loadUint(32);`                |
| `var (cs2, n) = cs.load_uint(32);` | `var cs2 = cs; var n = cs2.loadUint(32);` |

* If `cs~load_uint(…)` was used, `cs.loadUint(…)` behaves identically.
* If `cs.load_uint(…)` was used to obtain a copy, a different approach is required.

## Added functions

Tolk provides functions out of the box.

The [standard library](/languages/tolk/features/standard-library) is split into multiple files. Functions from `common.tolk` are always available, and most FunC analogues are included. Functions from other files must be explicitly imported:

```tolk theme={"theme":{"light":"github-light-default","dark":"dark-plus"},"languages":{"custom":["/resources/grammars/tolk.tmLanguage.json","/resources/grammars/tlb.tmLanguage.json","/resources/grammars/fift.tmLanguage.json","/resources/grammars/tasm.tmLanguage.json","/resources/grammars/func.tmLanguage.json"]}}
import "@stdlib/gas-payments"

// now `calculateGasFee()` and other symbols are visible
```
