Мир сегодня с "Юрий Подоляка"
Мир сегодня с "Юрий Подоляка"
Труха⚡️Україна
Труха⚡️Україна
Николаевский Ванёк
Николаевский Ванёк
Мир сегодня с "Юрий Подоляка"
Мир сегодня с "Юрий Подоляка"
Труха⚡️Україна
Труха⚡️Україна
Николаевский Ванёк
Николаевский Ванёк
TL

TOLK lang

Channel devoted to TOLK — "next-generation FunC" — a language for writing smart contracts in TON
Рэйтынг TGlist
0
0
ТыпПублічны
Вертыфікацыя
Не вертыфікаваны
Надзейнасць
Не надзейны
Размяшчэнне
МоваІншая
Дата стварэння каналаСерп 05, 2024
Дадана ў TGlist
Лют 21, 2025

Рэкорды

20.04.202523:59
234Падпісчыкаў
30.04.202523:59
300Індэкс цытавання
30.01.202523:59
1.7KАхоп 1 паста
15.03.202515:09
618Ахоп рэкламнага паста
12.04.202523:59
5.39%ER
28.01.202510:57
1026.05%ERR

Развіццё

Падпісчыкаў
Індэкс цытавання
Ахоп 1 паста
Ахоп рэкламнага паста
ER
ERR
ЛЮТ '25БЕР '25КВІТ '25

Папулярныя публікацыі TOLK lang

08.04.202509:12
🫧 Tolk v0.11: type aliases, union types, and pattern matching

This update might confuse you at first. You may wonder: "Why do we need this? How will it be useful?". But in the end, you'll see how everything comes together bringing seamless and generalized message handling.

✅ Notable changes in Tolk v0.11:

1. Type aliases type NewName =
2. Union types T1 | T2 | ...
3. Pattern matching for types
4. Operators is and !is
5. Pattern matching for expressions
6. Semicolon for the last statement in a block can be omitted

PR on GitHub with detailed info.

✔ Type aliases

Tolk now supports type aliases, similar to TypeScript and Rust.



An alias creates a new name for an existing type but remains interchangeable with it. No performance overhead — a compile-time feature.

✔ Union types `T1 | T2 | ...`

They now allow a variable to hold multiple possible types.



Nullable types T? are now formally T | null.

At the TVM level, union types work as tagged unions — similar to Rust enums but more flexible.

✔ Pattern matching

The only way to work with union types is matching them:



Matching is based on smart casts — inside each branch, the variable is automatically narrowed to the matched type.
 
It can also be used as an expression:



So, `match` + smart casts are our way for union types. You may notice that it's close to enums in Rust. But we don't have enum. Union types are more general and powerful.

✔ `match` for expressions



As you see, match also works for constant expressions, similar to switch in other languages.

✔ Union types and TL/B `Either`

T1 | T2 will be directly mapped to TL-B (Either T1 T2).
Look how clean this is: (Either SmallPayload LargePayload) becomes



No need to manually handle bits from the slice — it's naturally expressed in the type system!

✔ Union types and TL/B constructors

T1 | T2 | ... is a typed way to describe multiple constructors from TL/B. Generally, they can be used anywhere inside a storage or a message.

Moreover — handling incoming messages is beautifully expressed with union types.

✔ Union types and future structures

The ultimate goal? You'll describe each incoming message as a struct, create a union type for them, parse a slice, and just match over variants:



🌳 So, union types (that perfectly work with tensors) will seamlessly work with structures. With union types, you will declare both Either and different kinds of messages. Combined with intN and other types, they will allow to express (almost) any practical TL/B construction. They are not limited to message routing — in other words, message routing does not differ from handling any field, any storage, or any cell in general.
Увайдзіце, каб разблакаваць больш функцый.