Adding the ?. operator to D

Per Nordlöw per.nordlow at
Sat Sep 12 16:51:20 UTC 2020

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


     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].


More information about the Digitalmars-d mailing list