You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In FunC, strings are enclosed in double quotes `"`, like `"this is a string"`.<br />
13
-
Special characters like `\n` and multi-line strings are not supported.<br />
14
-
Optionally, a type can be specified after a string literal, such as `"string"u`.
13
+
You can optionally specify a type after the string literal, such as `"string"u`.<br />
14
+
Special characters like `\n` are not supported, but you can create multi-line <br /> strings simply by writing the text across multiple lines, like this:
15
+
```
16
+
;; somewhere inside of a function body
17
+
18
+
var a = """
19
+
hash me baby one more time
20
+
"""h;
21
+
var b = a + 42;
15
22
23
+
b; ;; 623173419
24
+
```
16
25
17
26
FunC supports the following string types:
18
27
* without type – Used for `asm` function definitions and defining a slice constant from an ASCII string.
19
28
*`s`— Defines a raw slice constant using its contents (hex-encoded and optionally bit-padded).
20
29
*`a`— Creates a slice constant containing a `MsgAddressInt` structure from a given address.
21
30
*`u`— Converts an ASCII string into an integer constant, representing its hex values.
22
-
*`h`— Generates an integer constant from the first 32 bits of the string’s SHA-256 hash.
31
+
*`h`— Generates an integer constant from the first 32 bits of the string's SHA-256 hash.
23
32
*`H`— Generates an integer constant from the full 256-bit SHA-256 hash of the string.
24
33
*`c`— Generates an integer constant from the `crc32` value of the string.
25
34
@@ -38,13 +47,14 @@ The following string literals produce these corresponding constants:
38
47
39
48
FunC allows a broad range of identifiers for functions and variable names.
40
49
Any **single-line string** that meets the following conditions qualifies as a valid identifier:
41
-
- It **does not** contain special symbols: `;`, `,`, `(`, `)`, `` spaces including tabs, `~`, and `.`.
50
+
- It **does not** contain special symbols: `;`, `,`, `(`, `)`, `[`, `]`, spaces including tabs, `~`, and `.`.
42
51
- It **does not** start as a comment or a string literal (i.e., with `"` at the beginning).
43
52
- It is **not** a number literal.
44
53
- It is **not** an underscore `_`.
45
54
- It is **not** a reserved keyword. Exception: if it starts with a backtick `` ` ``, it must also end with a backtick and cannot contain any additional backticks inside.
55
+
- It is **not** a name of a [builtin](https://github.com/ton-blockchain/ton/blob/5c392e0f2d946877bb79a09ed35068f7b0bd333a/crypto/func/builtins.cpp#L1133).
46
56
47
-
Additionally, function names in function definitions can start with `.` or `~`.
57
+
Additionally, **function** names in function definitions can start with `.` or `~`.
48
58
49
59
Examples of valid identifiers:
50
60
-`query`, `query'`, `query''`
@@ -130,4 +140,3 @@ all optimizations and pre-computations apply efficiently—unlike the older appr
0 commit comments