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

Add support for const blocks #153

Merged
merged 2 commits into from
Oct 12, 2020
Merged

Add support for const blocks #153

merged 2 commits into from
Oct 12, 2020

Conversation

udoprog
Copy link
Collaborator

@udoprog udoprog commented Oct 12, 2020

This PR adds support for constant blocks:

let value = const { 1 + 3 };
println!("{}", value);

Constant blocks are similarly to constant functions and declarations evaluated at compile time. They are a kind of anonymous constant declaration that can be used inline.

They have the same rules for scope evaluation as other constant eval: They can only reference and use other constant values.

There's an outstanding issue with constant evaluation that was discovered when working with this, which has been outlined in #154.

@udoprog udoprog added the enhancement New feature or request label Oct 12, 2020
@udoprog udoprog merged commit 24b35c1 into master Oct 12, 2020
@udoprog udoprog deleted the const-blocks branch October 12, 2020 18:14
@udoprog udoprog added the changelog Issue has been added to the changelog label Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog Issue has been added to the changelog enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant