UFCS and constructors

Maxim Fomin maxim at maxim-fomin.ru
Tue Jul 2 13:16:39 PDT 2013


On Tuesday, 2 July 2013 at 19:47:07 UTC, Timon Gehr wrote:
>
> Analogies are always broken, but the rest of the post reads to 
> me roughly like:
>
> "Dogs are not pets, and should not be treated as such.
> They are fundamentally different from pets.
>
> Also, there are no other pets that bark, so it's incredibly 
> bizarre as well as inconsistent with the rest of the notion of 
> a 'pet' to have a pet dog.
>
> - Tmion M Gehr
> "
>

class A
{
   this() {}
   void foo(){}
}

A a = new A; // calls ctor, not foo

Of course constructors are special because not any function is 
called upon object construction. Same logic was made when ability 
to overload some operators was blocked. All operators are, well, 
operators but you cannot overload all of them. It appears that 
sometimes it does make sense to restrict operation on some 
particular elements of the set and sometimes not.

Anyway, without final decision on this issue, there would be 
endless controversy between those who point on commonness of all 
functions and those who point on peculiarity of some of them.


More information about the Digitalmars-d mailing list