Is all this Invarient **** er... stuff, premature optimisation?
Walter Bright
newshound1 at digitalmars.com
Tue Apr 29 03:14:15 PDT 2008
Lionello Lunesu wrote:
>
> "Walter Bright" <newshound1 at digitalmars.com> wrote in message
> news:48169E90.6050700 at digitalmars.com...
>> Me Here wrote:
>>> Janice Caron wrote:
>>>> Functions don't overload on return value.
>>> They don't? Why not? Seems like a pretty obvious step to me.
>>
>> Type inference in D is done "bottom up". Doing overloading based on
>> function return type is "top down". Trying to get both schemes to
>> coexist is a hard problem.
>
> But a function's result can be overloaded using "out", so why can't it
> be overloaded using the return value?
We know what the type of the out argument is. The problem with return
value overloading is not knowing what the type should be.
> Can't the compiler treat a return value as an implicit out argument?
Suppose the return value is used as an argument to another function with
overloaded versions. Rinse, repeat. The combinations grow out of control.
More information about the Digitalmars-d
mailing list