UFCS with constructors

Ali Çehreli acehreli at yahoo.com
Wed Nov 6 10:02:31 PST 2013


On 11/06/2013 09:46 AM, Maxim Fomin wrote:

 > On Wednesday, 6 November 2013 at 17:10:34 UTC, Ali Çehreli wrote:
 >>
 >> I would be very surprised if unary "-" produced a different type from
 >> the operand:
 >>
 >> Ali
 >
 > Operator does not produce type, it produces value of expression, and
 > type of expression happens not to be the type you expected.

Thanks. That's what I meant. :)

 > But such
 > expectations need not correspond to language rules (try to think from
 > from language laywer perspective).

I still argue that the expression -expr must have the same type as expr.

 > In bearophile case, I guess
 > Typedef!double overloads unary operator which returns double which is
 > primary reason for such behavior.

That's what I deduced from qznc's post and tried to mean that such 
behavior would be confusing to programmers.

Ali



More information about the Digitalmars-d-learn mailing list