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

feat: compile-time arithmetic for constants #3130

Closed
1 of 2 tasks
wraitii opened this issue May 11, 2023 · 1 comment · Fixed by #3132
Closed
1 of 2 tasks

feat: compile-time arithmetic for constants #3130

wraitii opened this issue May 11, 2023 · 1 comment · Fixed by #3132
Labels
enhancement New feature or request

Comments

@wraitii
Copy link
Contributor

wraitii commented May 11, 2023

Feature Request

Describe the Feature Request

The Cairo compiler should be able to calculate the compile-time value of constants, to make it easier to write such constants, e.g.:

const some_value = (256 * 1080) & 0xfaff + 1234; // should become 14336
const some_power_of_2: felt252 = 2**128 - 1; // should become 340282366920938463463374607431768211455

The only operator not currently in Cairo is **, but I feel an 'integer power' operator is super convenient when doing blockchain development, so it seems like it should be implemented as well.

Describe Preferred Solution

The compiler should just compile that arithmetic expression into its proper value.

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No
@wraitii wraitii added the enhancement New feature or request label May 11, 2023
@wraitii
Copy link
Contributor Author

wraitii commented May 11, 2023

(I intend to provide a PR for this soon)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant