default values for inout parameters

BCS BCS at pathilink.com
Tue Dec 5 15:46:51 PST 2006


Charlie wrote:
> The following fails with : Error: "" is not an lvalue
> 
> void f( inout char [] x = "" ){ }
> 
> void main ()
> {
>   f();
> }
> 
> 
> Why is this not allowed ?

What would this do?

void f( inout char [] x = "" )
{
	x = "world";
}

It amounts to "take a literal reference to a static string and set it to 
something else". It doesn't really have a meaning.

You could try shelling it by hand.

void f() { char[] x = null; f(x);}



More information about the Digitalmars-d-learn mailing list