Is case var(var x, var y) a valid syntax ?

Alan Malloy amalloy at google.com
Mon Sep 7 09:36:09 UTC 2020


I would be very surprised if that were valid. The inner vars are fine, of
course. However, your outer one has not replaced a type, but a
deconstructor reference, or whatever we're calling the opposite of a
constructor. "Any object which can be deconstructed into two constituent
objects" will surely not be a useful query very often, and I wouldn't
expect the language to support it.

On Mon, Sep 7, 2020, 1:24 AM Remi Forax <forax at univ-mlv.fr> wrote:

> Just a question,
> do we agree that the syntax below is valid ?
>
>   Point point = ...
>   switch(point) {
>     case var(var x, var y): ...
>   }
>
> i.e. that var can be written everywhere there is a type in a Pattern.
>
> Rémi
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20200907/619dd355/attachment.htm>


More information about the amber-spec-experts mailing list