A peek at the roadmap for pattern matching and more

Brian Goetz brian.goetz at oracle.com
Wed Aug 12 22:18:18 UTC 2020


> 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 ?

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.

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




More information about the amber-spec-experts mailing list