Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce comptime builtins corresponding to FunC string literal types #444

Closed
6 tasks done
anton-trunov opened this issue Jun 20, 2024 · 1 comment · Fixed by #787
Closed
6 tasks done

Introduce comptime builtins corresponding to FunC string literal types #444

anton-trunov opened this issue Jun 20, 2024 · 1 comment · Fixed by #787
Assignees
Labels
feature: builtins Builtin functions scope: partial-eval The constant and partial evaluation optimization mechanisms (src/optimizer/constEval.ts)
Milestone

Comments

@anton-trunov
Copy link
Member

anton-trunov commented Jun 20, 2024

like h, c, etc. See https://docs.ton.org/develop/func/literals_identifiers.

I don't think we should extend the syntax of string literals with these suffixes, because those are too cryptic for beginners, we should just introduce those as compile-time builtin functions, like crc32("foobar") as a Tact analogue for "foobar"c in FunC.

  • "string"s — defines a raw slice const by its contents (hex-encoded and optionally bit-padded) [added in PR #787 - rawSlice("string")];
  • "string"a — creates a slice const containing MsgAddressInt structure from a specified address [already have it: address("string")];
  • "string"u — creates an int const that corresponds to the hex values of the provided ASCII string [added in PR #787 - ascii("string")];
  • "string"h — creates an int const that is the first 32 bits of the SHA256 hash of the string [no need: can be solved with sha256 and a bit mask, this will be optimized in compile-time];
  • "string"H — creates an int const that is all 256 bits of the SHA256 hash of the string [already have it: sha256("string")];
  • "string"c — creates an int const that is crc32 value of the string [added in PR #787: crc32("string")].
@Gusarich
Copy link
Member

Gusarich commented Sep 3, 2024

  • "string"a — creates a slice const containing MsgAddressInt structure from a specified address;

this one is an already existing address()

@verytactical verytactical added scope: partial-eval The constant and partial evaluation optimization mechanisms (src/optimizer/constEval.ts) and removed scope: const-eval labels Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: builtins Builtin functions scope: partial-eval The constant and partial evaluation optimization mechanisms (src/optimizer/constEval.ts)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants