A peek at the roadmap for pattern matching and more

forax at univ-mlv.fr forax at univ-mlv.fr
Wed Aug 12 22:48:08 UTC 2020


----- Mail original -----
> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Envoyé: Jeudi 13 Août 2020 00:18:18
> Objet: Re: A peek at the roadmap for pattern matching and more

>> There is nothing on the meaning of "this" in the block of with, i
>> believe that like a constructor, "this" should be a reference to the
>> instance on which with is called and be final ?

ok, i said two different things in the same sentence, "like a constructor" and the "receiver of with" sorry.

> 
> This is one possible interpretation, yes.  But, it's not clear whether
> this carries its weight.
> 
> It would have the advantage that you could call methods on the
> reconstruction target, but has the same disadvantage as the name
> resolution for inner classes, which offers all sorts of
> puzzlers-in-waiting, since `foo()` might now be a method on the target,
> or a method in the local context.   I think "lambda" is a better model
> than "anonymous constructor body" here.

Choices are:
1/ the enclosing instance like in lambda
2/ the receiver of "with"
3/ the newly created instance like in a constructor
4/ a poison

I'm not sure lambda is the best model, i'm betting safely on 4 for now.

> 
> (In any case, observant readers will notice that it is a state monad in
> disguise.)

Rémi


More information about the amber-spec-experts mailing list