> From: "Brian Goetz" <brian.go...@oracle.com>
> To: "Remi Forax" <fo...@univ-mlv.fr>
> Cc: "amber-spec-experts" <amber-spec-experts@openjdk.java.net>
> Sent: Wednesday, March 30, 2022 2:42:38 AM
> Subject: Re: [External] : Re: Declared patterns -- translation and reflection

>> 1/ conceptually there is a mismatch, the syntax introduce names for the
>> bindings, but they have no names at that point, bindings only have names 
>> AFTER
>> the pattern matching succeed.

> I think you have missed the point here. The names serve the implementation of
> the pattern, not the interface -- just as parameter names to methods do. As 
> you
> see in the example, these are effectively blank final locals in the body of 
> the
> pattern, which must be assigned to. (I'd have pointed this out if this were
> actually a message on declaring deconstructors, but since the message is on
> translation and reflection I didn't want to digress.)

>> 2/ sending the value of the binding by name is alien to Java. In Java, 
>> sending
>> values is by the position of the value.

> It's not by name. I don't know where you got this idea.

>> 3/ the conceptual mismatch also exists at runtime, you need to permute the 
>> value
>> of bindings before creating the carrier because a carrier takes the value of
>> the binding by position while the code will takes the value of the bindings 
>> by
>> name (you need the equivalent of MethodHandles.permuteArguments() otherwise 
>> you
>> will see the re-organisation of the code if they are side effects).

> It's not by name. I don't know where you got this idea.
I think i understand the underlying semantics of the syntax, i'm not 100% 
confident. 
You know that it's not about the syntax per se but what the syntax try to 
communicate to the users. 

The problem with the proposed syntax is that you invent a new kind of variable, 
until now, we had local variables and fields (and array cells but those have no 
name). 

Your binding is a new kind of variable. It means that 
- as a user, i need to learn new rules: can i use the value of a binding to 
compute the value of another one, can i declare a binding final ? can i capture 
a binding in a lambda/anonymous class ? etc 
- the JLS needs to artificially grows to cover all these rules 
- the JVMS needs to be updated, more questions: do we need an attribute 
LocalBindingTable like we have a LocalVariableTable 
- tools needs to be updated: how debuggers reflects bindings, is it another 
tables in the UI ? Do/Can the debugger allows to chain the value of the binding 
while a user steps into the code, etc 

All this pain, because you want to name bindings. 

Rémi 

Reply via email to