Is all this Invarient **** er... stuff, premature optimisation?

e-t172 e-t172 at akegroup.org
Tue Apr 29 03:13:31 PDT 2008


Lionello Lunesu a écrit :
> 
> "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?
> 
> Can't the compiler treat a return value as an implicit out argument?

Consider this:

int foo();
float foo();

void bar(int a);
void bar(float a);

Then this:

void main()
{
	bar(foo());
}

There is an obvious problem here.



More information about the Digitalmars-d mailing list