-
Notifications
You must be signed in to change notification settings - Fork 493
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
Document expression evaluation order #248
Comments
The referenced discussion is about evaluation order. Operator precedence is something different, it's about whether |
This is what opening issues at 1AM does. Title fixed. Operator precedence is already documented. |
referring rust-lang/rust#72763: Is this the intended behaviour for a |
I brought this up in the help forums, related to order of structure initialization. Tuples are guaranteed to be initialized in order. How about structs? Doing some marshalling. So I have things like
where "getnextvalue()" is reading a value from some stream and thus has side effects. How about the nested case?
Consensus seems to be that the structure field initializers are executed left to right, as with tuples and arrays, but no spec actually says that. It's probably worth nailing down, so some later optimization doesn't break that assumption. For example, if I have
and then initialize with
A Reddit discussion four years ago indicated confusion over this issue. Nobody is totally sure. |
See also, https://internals.rust-lang.org/t/rust-expression-order-of-evaluation/2605/32
The text was updated successfully, but these errors were encountered: