Record pattern: matching an empty record
Brian Goetz
brian.goetz at oracle.com
Sun Mar 13 15:21:05 UTC 2022
Given a record R, and a record pattern R(P*), where P* is a list of
nested patterns of the same arity as R's components, then
x matches R(P*)
iff
x instanceof R
&& R(var alpha*) // always true, just binds
&& \forall i alpha_i matches P_i
If P* is empty, the last clause is vacuously true.
On 3/13/2022 11:09 AM, Remi Forax wrote:
> Hi all,
> while writing the prototype of the runtime,
> i found a case i think we never discuss, can we match an empty record ?
>
> record Empty() { }
>
> switch(object) {
> case Empty() -> ... // no binding here
>
> I think the answer is yes because i don't see why we should do a special case for that, but i may be wrong.
>
> Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20220313/97e47ac1/attachment.htm>
More information about the amber-spec-experts
mailing list