default values for inout parameters

BCS BCS at pathilink.com
Tue Dec 5 16:10:13 PST 2006


Charlie wrote:
> Yea I was trying to abuse it, you're right it shouldn't work with 
> default parameters, what I was really trying to do was something like
> 
> char [] x = char[]
> 
> Charlie
> 

Are you looking for some sort of "stuff in a throw away value" feature?

void foo(int i, inout char[] foo = /** somthing **/ )
{
	foo = "hello";
}

char[] a;
foo(1, a);
assert(a == "hello");
foo(1); // no side effects

What would be nice would be something like "Non l-values used for inout 
parameters get passed as copies and discarded after use."




More information about the Digitalmars-d-learn mailing list