> From: "Brian Goetz" <[email protected]>
> To: "Remi Forax" <[email protected]>
> Cc: "amber-spec-experts" <[email protected]>
> Sent: Friday, January 26, 2024 7:11:29 PM
> Subject: Re: Towards member patterns
>>> - We basically agree that at the use site, we have all the qualification
>>> modes
>>> we have with methods { constructor qualified with package, static member
>>> qualified with type, instance member qualified with receiver } , and
>>> possibly,
>>> an additional mode of "instance qualified by type"
>> for me the special mode is more 'instance member qualified with receiver' but
>> yes,
> I think you'll find once you start writing code with it that the
> receiver-qualified version is more common than you think. And, if we only
> could
> have one, it has to be the receiver-qualified one, since you can get to the
> "unbound" version by specifying the receiver explicitly (use the match
> candidate as an explicit receiver), but you can't go the other way -- if all
> you have is unbound, you can't do regular expressions, you can't do type
> classes, you can't do anything virtual where the pattern operates on something
> other than itself. So receiver-qualified is the "primitive" and the other is a
> convenience syntax that we can layer on top of it if we need.
By special mode, i mean having the bound being speicifed explicitly even if it
is this.
>>> - The details of the last one are not fully worked out, that's fine
>>> - The details of exhaustiveness are not fully worked out, that's fine
>>> Is that about right?
>> yes,
>> and there is also how to send parameters to the pattern method (and if this
>> is
>> something we should support) that can be added to that list.
> This one is interesting. I was convinced at first we needed it, but I now
> think
> we can do without it (in this form), and we can get the effect of it in a more
> organic way.
> In any case, glad that we're on the same page. More docs coming.
It just occurs to me that there is another hurdle to figure out, annotations.
Annotations are not really reversible, the way you specify annotations on a
return type (on the method) and on parameter types is different, it's not the
same @Target.
If you have an annotation that log the return value (a classical AOP exercise),
for an inverse method, do you put it on the parameters (in that case where) or
on the return type knowing that in fact it's a parameter ?
And you have the explicit "this" (to be able to annotate it), which on an
inverse method is a true parameter unlike the others.
class Foo {
inverse List<String> bar(Foo this, Baz baz) {
...
}
}
regards,
Rémi