Feedback on nulls in switch
Brian Goetz
brian.goetz at oracle.com
Tue Aug 11 14:32:37 UTC 2020
>> I think we all are going to have to learn to read the bottom of a switch as a probable catch-all.
>> Maybe we want to add a modifier to enforce the assumption, and exclude the implicit default; I’ve suggested ‘final case’ as a cite bikeshed color.
> :-) I woke up this morning and had almost exactly this thought.
Now you're on a better track. The problem, if there is one, is the
schizoid treatment of totality in switch, which (I'm sure you remember
well) was a deliberate compromise we made to avoid having a
proliferation of switch-like constructs. Having a way to add back
totality explicitly may be a path to helping people see the totality
more clearly.
We've considered exactly this, but we're holding our opinion on it
because, at this point, it's the kind of attractive-syntax-nuisance that
tends to distract our attention from the more important task of ensuring
that pattern matching has a sound basis. So we're holding off on "what
other things do we have to do to make this more obvious" until later.
An explicit way to opt into totality for statement switches is
definitely one possibility.
> I
> think all my concerns go away with this syntax/semantic:
Without commenting on this particular bikeshed color, I think you're
well on your way to snapping yourself out of the local minima you found
yourself in. It sounds like, while you thought you didn't like the
nullity semantics, what you really didn't like is that the totality was
too subtle.
More information about the amber-dev
mailing list