[Dlang-internal] How about `and` and `or` like in Python?
Dennis
dkorpel at gmail.com
Thu Oct 3 23:35:10 UTC 2019
On Thursday, 3 October 2019 at 22:53:55 UTC, snow jhon wrote:
> Personally, I think this would make the code less readable; the
> current way creates more of a distinction between operators and
> operands.
With a syntax highlighter that makes them bold you don't have
this problem.
Also, && and || are actually pretty exceptional operators. Most
operators are simply functions mapping directly to hardware
instructions with special symbol notation. In D they can be
overloaded using functions opBinary or upUnary. && and || have
lazy evaluation and therefor introduce control flow unlike
functions whose parameters are evaluated first.
Zig is designed in such a way that all control flow happens
through keywords. The bitwise and/or functions use the & and |
symbols, but boolean and/or use the keywords [1]. (Also the
ternary operator is just `if` and `else` forming an expression
instead of a statement.)
This gives an actually useful distinction between keywords and
symbols. But like I said, trying to change D on that aspect at
this point is not useful.
[1] https://ziglang.org/documentation/0.5.0/#Operators
More information about the Dlang-internal
mailing list