-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
"Not" instead of "!" #6625
Comments
(also I'm biased against this because |
Since bool negation is quasi-control flow it can be either way, i think the problem with |
Just as personal preference, reading |
I honestly don't know why I care about this, but status-quo feels a lot clearer to me; probably having worked with Lua with its special condition evaluations. Examples with booleans and boolean vectors: let
In status-quo, But I guess it's ultimately purely a question of style (-> whether your habit/background comes from C or Python). The proposal does lead away from the current rule-of-thumb: control-flow-via-keywords. |
I would have less of a problem with |
I think there's definitely a matter of preference here, but for me it comes down to how tightly the operator binds. Looking at the precedence table for Zig:
You can see that the unary not is in the same block as the other unary operators. Which means that in the example There might be an argument that the unary not should also be moved to be closer to |
#114 is still planned for anything but trivially obvious operator precedence |
Was this intended to be closed? Though the case for this issue is stronger once we have #114, they really are independent. Btw Lua also spells it “not“ :) |
Yes; some parts of zig's syntax are stabilized and this is one of them. I know it doesn't feel good to get your proposal closed but by closing it quickly when I know it is not going to be changed, I'm trying to save your time and everyone else's who participates in the thread, so that you can spend your energy on issues that may ultimately end up having an impact. |
Not at all! I’m actually ambivalent; accepting this proposal would imply that language stability is much farther than I would prefer! I am happy that this thread documents the decision for anyone else who might be curious. Thanks! |
Should we use a
not
operator instead of unary!
for logical NOT?This would be consistent with the spelling of
and
andor
logical operators. It's also how Eiffel and Python do it (as well as Perl and Pascal).It would also make the meaning of
!
more focused in Zig, to be used for error unions.(That'd leave just the distinct
!=
operator related to negation, again just like Python. I won't suggest using the SQL style<>
instead 😄 ).The text was updated successfully, but these errors were encountered: