Commit 578df21
committed
[Tolk] Implement methods for any types as extension functions
In FunC, any function could be called `f(arg)` or `arg.f()`.
You had to call `cell.cell_hash()` / `slice.slice_hash()`:
these were two different global-scope functions.
Now, Tolk, as other languages, separates functions from methods.
It drops the ability to call a function via dot;
you can only call a method (for an object type).
> fun cell.hash(self): int ...
> fun slice.hash(self): int ...
With methods, stdlib functions became short:
`t.size()` instead of `t.tupleSize()`, and so on.
Methods can be declared for any type, including generics.
Calling a method, the compiler does type matching to detect
the only method from many equally named. This could be
generalized to functions overloading some day.1 parent 720a173 commit 578df21
File tree
153 files changed
+2236
-1227
lines changed- crypto/smartcont/tolk-stdlib
- tolk-tester/tests
- invalid-declaration
- invalid-semantics
- invalid-symbol
- invalid-syntax
- invalid-typing
- warnings-not-errors
- tolk
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
153 files changed
+2236
-1227
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | 25 | | |
32 | 26 | | |
33 | 27 | | |
| |||
0 commit comments