Am 14.11.2012 20:07, schrieb Timon Gehr:
> On 11/14/2012 06:30 PM, Rob T wrote:
>> On Wednesday, 14 November 2012 at 09:16:13 UTC, Walter Bright wrote:
>>>> I'm not requesting this to be a feature of D, I'm only asking why it
>>>> is not
>>>> being done.
>>>
>>> Because types are resolved bottom-up, and if the return type were part
>>> of the overloading, there would be no sensible rule to determine the
>>> types.
>>
>> But doesn't the compiler already have to perform overload-like decision
>> making on return types in the "alias this" case, esp once multiple
>> conversions are allowed?
>>
>> class A{
>>    int i;
>>    bool b;
>>    alias i this;
>>    alias b this;
>> }
>>
>> main()
>> {
>>    auto a = new A;
>>    int i = a;
>>    bool b = a;
>> }
>>
>> --rt
> 
> alias this is not the best example, but the necessary logic is basically 
> already in the compiler.
> Lambda parameter type deduction based on the expected type is a similar task.
> 
> It is not being done because it is not being done. Full type inference would 
> be even more fun.

In the lambda case it's return type deduction and not overload resolution. 
Those are actually two
very different things.

Reply via email to