function overload on full signature?

Timon Gehr timon.gehr at gmx.ch
Wed Nov 14 11:07:11 PST 2012


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.


More information about the Digitalmars-d mailing list