in, out and inout for function arguments

SKS skshukla_ncr at yahoo.co.in
Thu Oct 12 01:46:32 PDT 2006


I have a program:
import std.file;

public static void foo(in int i, out int o, inout int io)
{
	i++; o--; io++;
	printf("foo %d, %d, %d\n", i, o, io);
}

int main (char[][] args)
{
	int i1 = 1, i2 = 123, i3 = 234;
	printf("before foo %d, %d, %d\n", i1, i2, i3);
	foo(i1, i2, i3);
	printf("after foo %d, %d, %d\n", i1, i2, i3);
	return 0;
}

Why this compiles successfully with dmd compiler?
I expect 'out' parameter modification to cause error. Is it a bug in compiler
implementation or wrong usage?

Also looking at sample programs I don't find in/out usage as common?



More information about the Digitalmars-d mailing list