[Dlang-internal] How about `and` and `or` like in Python?

Paul Backus snarwin at gmail.com
Thu Oct 10 18:01:36 UTC 2019


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. :)


More information about the Dlang-internal mailing list