UFCS and constructors

bearophile bearophileHUGS at lycos.com
Tue Jul 2 19:00:45 PDT 2013


deadalnix:

> The whole point of UFCS is to be able to provide additional 
> custom "methods" to a object (class or struct). Constructor 
> UFCS don't fulfill that use case.
>
> Nothing is removed from the language as factories method can be 
> introduced anyway.

This frames the topic in a wrong way. Constructors are not normal 
functions, they are special, but functional languages show us 
that's it's a very good idea to see them as functions.

And the original point of UFCS doesn't matter much. What matters 
is what are the practical disadvantages of allowing UFCSyntax for 
constructors (like the original post in this thread), and what 
are their practical advantages/uses (like a handy usage in UFCS 
chains). Then we take a look at what's the resulting balance and 
we decide. And such decisions should then become the written 
specifics of this part of the D design.

Bye,
bearophile


More information about the Digitalmars-d mailing list