Adding the ?. operator to D

Atila Neves atila.neves at gmail.com
Thu Sep 17 11:35:45 UTC 2020


On Saturday, 12 September 2020 at 16:51:20 UTC, Per Nordlöw wrote:
> Has there been any discussions on adding the ?. operator to 
> simplify structure matching on class trees typically found in 
> compilers such as dmd.
>
> Basically, implemented via lowering of
>
>     C ?. EXPR
>
> to
>
>     C ? C.EXPR : EXPR.init
>
> when EXPR has type class or pointer and for the other cases 
> either
>
>     C ? C.EXPR : EXPR.init
>
> or perhaps even
>
>     C ? C.EXPR : nullable(EXPR).init
>
> if nullable is made part of the runtime or even builtin.
>
> Given that `C` is a class or pointer to an aggregate.
>
> C# supports has this [1].
>
> [1] 
> https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/member-access-operators#null-conditional-operators--and-

In general I'm wary of special syntax for particular instances of 
monads.


More information about the Digitalmars-d mailing list