Modifiable typesafe variadic arguments

BCS BCS at pathlink.com
Thu Jun 15 10:16:14 PDT 2006


Deewiant wrote:
> Daniel Keep wrote:
> 
>>Honestly, I think that when you ever pass something to a function that it can
>>change, there should be some explicit notice of this (like having to pass the
>>argument by address).
> 
> 
> I agree. Hence I still hope for my suggestion (which was originally someone
> else's idea, but I wrote it up at the D wish list,
> http://all-technology.com/eigenpolls/dwishlist/ ) requesting usage of explicit
> out/inout when calling to be implemented. Meaning, whenever you call a function
> with out/inout arguments, you specify out/inout at the call point as well as at
> the function definition.
> 
> 
On that thought, what is the easiest way to pass a copy in an inout arg 
or a dummy for an out?

this would be the effect, but its a bit verbose.

int  foo(inout int i, out int j)
{
	j = i;
	i = 1;
	return i+j;
}
...
	int i=1, k;
...
	{	// don't care about i or j's returned value;
		int i_ = i, j_;
		k = foo(i_, j_);
	}
...

something like this would be nice:


...
	int i=1, k;
...
	k = foo(i.dup, auto);
...

	



More information about the Digitalmars-d-learn mailing list