hg: amber/amber: hooking records to patterns

Brian Goetz brian.goetz at oracle.com
Fri Apr 6 19:58:52 UTC 2018

You're forgetting field accessor method handles.  You can express 
Foo::list as a field getter method handle, but then it has a return type 
of ArrayList.  You'd have to asType it to express it with a return type 
of List.  Its easy to represent a direct MH in the CP; its harder 
(though we can do it now) to represent an asType MH in the CP.

Besides, stable interfaces are a good thing.  (I could try and infer a 
method return type at runtime by analyzing its bytecode, but its better 
if the method says "I return List".  Same basic deal; the component MHs 
are implementation.)

On 4/6/2018 3:52 PM, forax at univ-mlv.fr wrote:
>> and we have a pattern that yields a binding variable of type `List`.  If
>> the component MH were Foo::list, it would (a) yield the wrong type, and
>> (b) the type might be unstable if the implementation were to change.
>> Having a stable descriptor for what the pattern yields as bindings as
>> separate from the implementation for how to produce those bindings is
>> necessary for stability.
> All the problems of type you can have are true not only for the extractor but also for the getter/component method too,
> so if you already the right type encoded in the component method, you do not need to provide the same information as a descriptor.

More information about the amber-dev mailing list