Project Elvis

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sun Oct 29 14:37:57 UTC 2017


On Sunday, October 29, 2017 14:27:34 Ola Fosheim Grøstad via Digitalmars-d 
wrote:
> On Sunday, 29 October 2017 at 11:23:19 UTC, Steven Schveighoffer
>
> wrote:
> >> So, what will the member function be called? «opElvis»? No…
> >
> > opCast for bool.
>
> That means you cannot create your own type-safe filtering
> mechanism, but will be forced to provide opCast for bool.

opCast with bool is precisely how you already provide overloads for dealing
with every other place in the language that a boolean condition is used -
the ternary operator, assertions, if statements, while loops, and for loops
(which I think is everything, but I could have missed something). As
proposed thus far, the Elvis operator is just the ternary operator where the
condition is reused as the first branch, so having it work with opCast fits
in perfectly with everything else.

What would you be looking to do that does not fit in with this?

- Jonathan M Davis




More information about the Digitalmars-d mailing list