Member lookup (Was: Re: UFCS and constructors)

Timon Gehr timon.gehr at gmx.ch
Tue Jul 2 08:12:45 PDT 2013


On 07/02/2013 03:00 PM, deadalnix wrote:
> On Tuesday, 2 July 2013 at 12:57:50 UTC, Timon Gehr wrote:
>> On 07/02/2013 09:35 AM, monarch_dodra wrote:
>>> ...
>>>
>>> One of the "big" problems with allowing UFCS and constructors is that a
>>> "." which meant "scope" can now mean "function call".
>>> ...
>>
>> I missed this point.
>>
>> 'One of the drawbacks of UFCS is that "bar.foo" which meant "scope
>> lookup" or "opDispatch instantiation" or "alias this lookup" can now
>> also mean "UFCS lookup".'
>>
>> Fixed.
>
> That is an issue, we have all of this, and prioritization mechanism is
> implementation defined right now.

Yup. I'll go with:

1: If member is present (current scope or super class scope), use that,
    otherwise try opDispatch in the same scopes. Block alias this at
    this point.

2: If no success, loop through all alias this definitions and apply 1.
    for the corresponding scopes. Collect possible members.

3: Error out if multiple possible distinct members.

4: Try UFCS rewrite if no matches.

(Of course, even checking whether a member is present, or looping over 
all alias this definitions are not entirely trivial processes themselves 
in the general case.)

This seems to be compatible with what DMD does.



More information about the Digitalmars-d mailing list