Skip to content

Commit 17768f7

Browse files
(FunC) Add clarifications for literals and identifiers (#1177)
* Update literals_identifiers.md * Update literals_identifiers.md * proofread --------- Co-authored-by: AlexG <39581753+reveloper@users.noreply.github.com>
1 parent 7dc1866 commit 17768f7

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

docs/v3/documentation/smart-contracts/func/docs/literals_identifiers.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,25 @@ Examples of valid literals: `0`, `123`, `-17`, `00987`, `0xef`, `0xEF`, `0x0`, `
1010
## String literals
1111

1212
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;
1522
23+
b; ;; 623173419
24+
```
1625

1726
FunC supports the following string types:
1827
* without type – Used for `asm` function definitions and defining a slice constant from an ASCII string.
1928
* `s`— Defines a raw slice constant using its contents (hex-encoded and optionally bit-padded).
2029
* `a`— Creates a slice constant containing a `MsgAddressInt` structure from a given address.
2130
* `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 strings SHA-256 hash.
31+
* `h`— Generates an integer constant from the first 32 bits of the string's SHA-256 hash.
2332
* `H`— Generates an integer constant from the full 256-bit SHA-256 hash of the string.
2433
* `c`— Generates an integer constant from the `crc32` value of the string.
2534

@@ -38,13 +47,14 @@ The following string literals produce these corresponding constants:
3847

3948
FunC allows a broad range of identifiers for functions and variable names.
4049
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 `.`.
4251
- It **does not** start as a comment or a string literal (i.e., with `"` at the beginning).
4352
- It is **not** a number literal.
4453
- It is **not** an underscore `_`.
4554
- 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).
4656

47-
Additionally, function names in function definitions can start with `.` or `~`.
57+
Additionally, **function** names in function definitions can start with `.` or `~`.
4858

4959
Examples of valid identifiers:
5060
- `query`, `query'`, `query''`
@@ -130,4 +140,3 @@ all optimizations and pre-computations apply efficiently—unlike the older appr
130140

131141

132142
<Feedback />
133-

0 commit comments

Comments
 (0)