TGViewer
TOLK lang TOLK lang @tolk_lang Β· 809 subscribers
Post #20 6.7K
🫧 Tolk v0.12: structures, generics, and methods

Finally! Or maybe not yet?

This update brings Tolk one step closer to its final form by introducing:

βœ… Notable changes in Tolk v0.12:

1. Structures
2. Generics
3. Methods
4. Stdlib with short naming
5. Fift output enhancements

PR on GitHub with detailed info.

βœ” Structures

Looks like TypeScript β€” but works in TVM!


struct Point {
x: int;
y: int;
}

fun calcMaxCoord(p: Point) {
return p.x > p.y ? p.x : p.y;
}

// declared like a JS object
var p: Point = { x: 10, y: 20 };

// called like a JS object
calcMaxCoord({ x: 10, y: 20 });


Point a just named tensor β€” identical to (int, int) at the TVM level.

Key features:
- Compiler guesses what you mean β€” automatically:

fun loadData(): StoredInfo {
return {
counterValue: ...,
ownerAddress: ...,
}
}


- Works with shorthand syntax { x, y }
- Default values for fields are supported
- Nested objects are supported
- No overhead for single-field structs over a plain value
- Nullability, smart casts, union types, all language features β€” everything works

βœ” Generics

They exist only at the type level (no runtime cost):

struct Nullable<T> {
item: T? = null;
}


The type system becomes powerful enough to express complex scenarios:

struct Ok<TResult> { result: TResult }
struct Err<TError> { err: TError }

type Response<R, E> = Ok<R> | Err<E>;

match (r) {
Ok => { r.result }
Err => { r.err }
}


βœ” Methods β€” for any types

For structures:

fun Point.getX(self) {
return self.x
}

fun Point.create(x: int, y: int): Point {
return { x, y }
}


Or extend built-in types:

fun slice.load32(mutate self): int32 {
return self.loadInt(32);
}


Or β€” tensors, unions, generics, even "any receiver". A method is just an extension function with predictable resolution rules.

βœ” stdlib β€” with short methods naming


// before
someCell.cellHash();
someTuple.tupleSize();
someBuilder.getBuilderBitsCount();

// now
someCell.hash();
someTuple.size();
someBuilder.bitsCount();


Even more β€” some global functions are now static methods:

// before
getMyAddress();
setContractData(c);
getLogicalTime();

// now
contract.getAddress();
contract.setData(c);
blockchain.logicalTime();


It looks pretty, and since IDE suggest only available methods after dot, it's extremely useful. For a full list of renamings, consider documentation.

βœ” A long-awaited bonus for Fift ninja

Look at the PR and enjoy how readable Fift assembler output is. Yes, it contains original .tolk lines as comments! And yes, it works perfectly.

🌳 You now see how Tolk's features are aligning together towards automatic serialization, fully described by the type system. Cell references, constructor prefixes, message sending, and other use cases will be expressed with the features above.
  • πŸ”₯ 11
  • πŸ‘ 7
  • ❀ 6
  • πŸ’˜ 2
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 β†’