Feedback on nulls in switch

Brian Goetz brian.goetz at oracle.com
Tue Aug 11 14:24:45 UTC 2020


> What happened to the question mark syntax proposal for representing 
> nullable variable types? It looks like this would work here 

In a world where we had type cardinalities, then this would be the 
obvious answer -- `T!` is a non-nullable type pattern, `T?` is a 
nullable one, and `T` is, well, whatever we decide for legacy 
compatibility.

It was looking, for a few minutes, like we were heading in that 
direction in Valhalla, at which point the `T?` syntax became a 
possibility.  But those explorations in Valhalla-land crashed and 
burned, which left the pattern syntax with nothing to stand on.  We 
quickly realized that it would be seen as "glass 99% empty".

Not only would it have been perceived as a tease (you can just imagine 
the screeds), but in the absence of other uses of nullability in the 
language to connect to, it would be as ad-hoc and arbitrary as the "any 
X" proposal recently floated on the EG list. The only reason a T? syntax 
would work is because T? means "not nullable" in other contexts.


So, it was a passing exploration, which didn't pan out.  And that's OK.


More information about the amber-dev mailing list