TGViewer
TOLK lang TOLK lang @tolk_lang Β· 809 subscribers
Post #24 4.54K
🫧 Tolk v1.1: built-in map<K,V>, enums, private and readonly fields, method overloads

Two months have passed β€” maybe you even started to worry about the silence. The reason is simple: I worked on features that are "nice to have" but complex and time-consuming to implement β€” and they've only just been finished.

βœ… Notable changes in Tolk v1.1:

1. map<K, V> β€” a convenient zero-overhead wrapper over TVM dictionaries
2. enum β€” group numeric constants into a distinct type
3. private and readonly fields in structures
4. Overload resolution and partial specialization

PR on GitHub with detailed info.

βœ” Built-in maps

Forget about uDictSetBuilder, sDictGetFirstAsRef, and the endless boilerplate of low-level dict helpers. A universal map<K, V> now fully replaces them.


var m: map<int8, int32> = createEmptyMap();
m.set(1, 10);
m.addIfNotExists(9, -90);
m.delete(9); // now: [ 1 => 10 ]
m.exists(1); // true
m.isEmpty(); // false


Just m.get() β€” no need to care about cells and slices under the hood:

val r = m.get(1);
if (r.isFound) { // true
val v = r.loadValue(); // 10
}

// or if the key 100% exists
val v = m.mustGet(1); // 10


Easily iterate forward and backward:

var r = m.findFirst();
while (r.isFound) {
// use r.getKey() and r.loadValue()
r = m.iterateNext(r);
}


Any serializable keys and values β€” it just works:

map<address, Point>
map<Point, Cell<Extra>>
map<int32, map<int64, bool>>
...


All in all:
- self-explanatory methods, nicely suggested by IDEs
- DICTISETREF, DICTREPLACE, DICTUREPLACEGET, ... β€” 100+ asm instructions covered by the type system
- all deserialization to/from cells perfectly hidden by high-level API
- absolutely zero overhead compared to low-level TVM dictionaries

βœ” Enums

A long-awaited syntax feature for grouping constants.


// will be 0 1 2
enum Color {
Red
Green
Blue
}


Being integers at runtime, enums have their own place in the type system. They resemble TypeScript/C++ enums. (Unlike Rust, where each variant may have its own shape. In Tolk we have union types β€” a more powerful solution)


struct Gradient {
from: Color
to: Color? = null
}

var g: Gradient = { from: Color.Blue };
g.from == Color.Red; // false


Compatible with all language features: auto-serialization, exhaustive pattern matching, generics, etc.

βœ” Private and readonly fields

Fields can now have modifiers:
* private β€” accessible only within methods
* readonly β€” immutable after object creation


struct PosInTuple {
private readonly t: tuple
curIndex: int
}

fun PosInTuple.last(mutate self) {
// `t` is visible only in methods
// and cannot be modified
self.curIndex = self.t.size() - 1;
}


βœ” Partial specialization

Now it's possible to overload methods for "more specific" implementations:


// general implementation
fun Iterator<T>.next(self) { ... }

// a more specific one
fun Iterator<Cell<T>>.next(self) { ... }


In complex scenarios, this feature lets you adjust the behavior of specific types while keeping a common interface. It "just works", but internally the compiler was enhanced with shape of types, structural depth, type dominators, and several heuristics.

🌳 After Tolk v1.0 release, many people and companies started migrating from FunC to Tolk. I have received a lot of feedback and requests (and almost zero bug reports, huh). Meanwhile, a bigger roadmap is already in motion. In the near future I'll also try to close long-standing questions around TypeScript wrappers, and deliver proper from-scratch documentation.
  • πŸ”₯ 22
  • ❀ 10
  • πŸ‘ 5
  • ❀‍πŸ”₯ 3
More from @tolk_lang
  1. Jun 23, 2026🫧 Tolk v1.4.x: internal progress and maintenance Since the v1.4 release we've published T…
  2. May 11, 2026🫧 TON enters a new era of smart-contract development I promised this would happen in May.…
  3. Mar 27, 2026🫧 Tolk v1.3: moving toward a general-purpose language After the previous post, this relea…
  4. Mar 19, 2026🫧 Tolk v1.3... not released yet: what's happening inside I know it has been quiet. The la…
  5. Dec 5, 2025🫧 Tolk documentation β€” now complete and available for learning from scratch From now on,…
  6. Nov 14, 2025🫧 Tolk v1.2: rich bounced messages, cheap deployment, and a breaking change that you'll l…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook β†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 β†’