[Feature Request] Keywords for symbol operators

Steven Schveighoffer schveiguy at gmail.com
Mon Feb 26 03:59:00 UTC 2024


On Sunday, 25 February 2024 at 04:55:08 UTC, Danilo wrote:
> What about adding [keyword 
> forms](https://en.cppreference.com/w/cpp/language/operator_alternative) for some operator symbols, like in [C++](https://en.cppreference.com/w/cpp/language/operator_logical) ?
>
> ```
> Symbol | Keyword
> ----------------
>   !    |   not
>   !=   |  noteq
>        |
>   &&   |   and
>   ||   |   or
>        |
>   &    | bitand
>   |    | bitor
> ```

Use ufcs:

```d
bool and(bool a, bool b) => a && b;

    if(foo.and(bar))
// compare to
// if(foo and bar)
```

-Steve


More information about the Digitalmars-d mailing list