Overload resolution simplification

Brian Goetz brian.goetz at oracle.com
Sat Aug 10 10:29:27 PDT 2013

What makes you think the goal is encouraging explicit lambdas?

In the absence of overloading, inference works great.  What were proposing here is to have less magic in the interplay of overlaod resolution and inference.  

Sent from my iPhone

On Aug 10, 2013, at 7:36 AM, Remi Forax <forax at univ-mlv.fr> wrote:

> On 08/09/2013 02:19 AM, Dan Smith wrote:
>> We spent some time at the EG meeting last week talking about the overload resolution story in the presence of lambdas/method references (and, why not, type argument inference).  There are a lot of tricky dependencies here, and the goal is to find a balance between expressivity and simplicity.
>> The sense I got from the meeting is that, despite our efforts to refine the story (there have been a few iterations), we're still not there yet in terms of simplicity.  In particular, I think what's crucial about the model I presented is that users can identify the difference between implicit lambdas that get type checked pre-overload-resolution and post-overload-resolution; the sanity check I got is that nobody will be able to make that distinction.
>> A couple of days later, Maurizio pointed out that, as we've iterated on our libraries, we've largely abandoned the space of programs that requires some of the more complex overload disambiguation machinery.  And looking more closely at those use cases, we agreed that we've probably been focusing too much on some atypical patterns.
>> So, let me propose a greatly simplified but probably not-very-noticeably less expressive approach:
>> Overload resolution will only check the arity of all implicit lambdas and will ignore overloaded method references.  If the body of a lambda is important for disambiguation, it must have explicit parameter types.
>> Benefits of this approach:
>> - Very easy to understand -- it's mostly a syntactic distinction
>> - Consistent between all different patterns of overloading that were previously treated differently
>> - Facilitates a simple declaration-site warning check when method signatures conflict
>> - Encourages use of explicit lambdas -- clearly acknowledges that we can't solve all inference problems with implicit lambdas
>> - Avoids re-checking lambdas with different parameter types which means:
>> -- Typing of lambda bodies is easier for users to process
>> -- Implementations don't have to do speculative checking of arbitrary blocks of code
>> -- Bad theoretical complexity goes away
>> We've thought about it for a few days and think this is a much better scenario for users and more in line with the EG's expectations (based on feedback both this year and last).
>> Any questions/concerns?
> Thinking a bit more about this,
> it change a lot of assumptions we have used to make decisions in the past,
> by example do we really want a special syntax for implicit lambda with one parameter
> if we want to encourage use of explicit lambdas ?
> Rémi

More information about the lambda-spec-experts mailing list