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

Unparenthesized expressions aren't allowed in casts #120

Closed
jrmuizel opened this issue Jul 23, 2010 · 2 comments
Closed

Unparenthesized expressions aren't allowed in casts #120

jrmuizel opened this issue Jul 23, 2010 · 2 comments

Comments

@jrmuizel
Copy link
Contributor

u32(32-1) does not compile whereas u32((32-1)). It would be nicer if the extra brackets were not needed.

@graydon
Copy link
Contributor

graydon commented Jul 29, 2010

Both syntaxes are now invalid. You have two options: as lexemes "32u32 - 1u32", or as an expression "32-1 as u32". The "as" operator is low enough precedence that this doesn't require parens here.

We currently do no constant propagation or folding (there was a parser hack that attempted to do negation-folding on constants, but it was really awful and I've removed it), so both versions involve runtime arithmetic. A clever version of the compiler will fold it all away (and/or LLVM may just do so automatically).

@graydon
Copy link
Contributor

graydon commented Jul 29, 2010

Also note: if "1u32" makes your eyes hurt, it might be slightly less appalling if you make use of the underscores-in-numbers lexical treat at the suffix boundary: IOW write it as "1_u32".

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants