UFCS and constructors

Timon Gehr timon.gehr at gmx.ch
Tue Jul 2 20:17:04 PDT 2013


On 07/03/2013 03:37 AM, deadalnix wrote:
> On Tuesday, 2 July 2013 at 19:47:07 UTC, Timon Gehr wrote:
>> It is an artificial limitation, because you need to add an explicit
>> check after symbol lookup to ban constructors.
>>
>
> That seems very implementation defined.

It is true for two implementations and one spec I am aware of.

> The lookup will gives you a class or struct declaration,

Hopefully the UFCS lookup gives me a fully analysed call expression.
That's the point of specifying features by rewrite rules.

> so special casing the constructor is mandatory anyway.
>

Yes, the call expression needs some kind of check in order to support 
struct literals. Cancelling that support in some way in case the call 
expression happens to have been generated by an UFCS rewrite requires 
another check, which complicates the formal specification of UFCS for no 
gain.


More information about the Digitalmars-d mailing list