Pattern Matching for instanceof (Preview 2)

Brian Goetz brian.goetz at oracle.com
Thu Feb 6 22:04:05 UTC 2020


> I see two questions:
> - the grammar allows to mix var and non-var for a given reference type, i think that should only permitted if the non var is a deconstruction itself ?

More generally, any pattern can appear nested inside a deconstruction 
pattern -- another deconstruction pattern, a var (any) pattern, a type 
pattern, a constant pattern ... we may not have them all right now, but 
any pattern will do.

> - must the identifier of a pattern argument be the same name as the corresponding record component ?
>    To be coherent with the fact that constructors requires the same names.

Nope!  This is the use site; the client can name their locals however 
they like.  Invocation of deconstructors, like constructors, is positional.



More information about the amber-spec-observers mailing list