[Dlang-internal] How about `and` and `or` like in Python?
Murilo
murilomiranda92 at hotmail.com
Fri Oct 11 01:34:49 UTC 2019
On Thursday, 10 October 2019 at 18:01:36 UTC, Paul Backus wrote:
> On Tuesday, 1 October 2019 at 00:47:57 UTC, Murilo wrote:
>> In Python the && operator is `and` just like the || operator
>> is `or`. How about giving D this option? People could choose
>> to use either of those forms. I am suggesting you create the
>> `and` and `or` keywords to represent && and ||, respectively.
>> That should make the code more readable.
>
> bool and(bool a, lazy bool b) { return a && b; }
>
> if (cond1.and(cond2)) {
> // ...
> }
>
> Implementation of `or` is left as an exercise for the reader. :)
Thanks.
More information about the Dlang-internal
mailing list