-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
Logical operators ||
and &&
are short-circuiting
#665
Conversation
Note: This comment is obviated by #685, which makes The new test case does not use a In In This is arguably how it should work, or at least, changing the behavior would affect this case:
This currently prints 10, not 20. Edit: which is definitely a good thing, since that's how you can pass |
Another subtlety of short-circuiting: both macro arguments and interpolation outside strings can expand to just about anything, so I don't think those should necessarily get short-circuited in the first place. For example, |
ca6978c
to
5f01e1e
Compare
||
and &&
are short-circuiting.asm||
and &&
are short-circuiting
e2985c1
to
3ddd38a
Compare
This might be worth adding to 0.4.3 even if a later release will add lazily-evaluated expressions and revamp how short-circuiting works, because as-is this can already improve performance by not evaluating right-hand sides. |
388e182
to
524330f
Compare
5ce3c7a
to
90507ff
Compare
`true || X` short-circuits to 1 without evaluating X `false && X` short-circuits to 0 without evaluating X Fixes gbdev#619
90507ff
to
d0a91bf
Compare
true || X
short-circuits to 1 without evaluating Xfalse && X
short-circuits to 0 without evaluating XFixes #619