On 4/9/13 10:35 AM, deadalnix wrote:
On Tuesday, 9 April 2013 at 13:02:27 UTC, bearophile wrote:
deadalnix:

I don't think this makes any sense. Constructor are not regular
function.

From studying functional languages like Haskell I have learnt that
considering "constructors" like the other functions gives some
advantages. The uniformity of the idea of "function" is very useful.


Right now, in D, you'll find plenty of magic associated with
constructors. This is fundamentaly problematic when you want to disguise
them as functions.

I would be in general for reducing the magic associated with constructor
in order to allow them to behave like function, but right now, they are
different beasts.

They are different than regular functions by necessity. A constructor must start on an raw object ("unprepared" in a sense) and bring it to a meaningful state. In the case of immutable and const objects, that grants the constructor special characteristics that are very unlike regular functions. So they are special.

Andrei

Reply via email to