Array as an argument, ambiguous behaviour.

Cooler kulkin at hotbox.ru
Wed Jan 29 02:55:56 PST 2014


Consider 3 functions taking array as an argument:

void fun1(in  int[] x){...}
void fun2(ref int[] x){...}
void fun3(    int[] x){...}

auto a = new int[10];

fun1(a); // Guaranteed that "a" will not be changed
fun2(a); // Guaranteed that we will see any change to "a", made 
in fun2()
fun3(a); // Changes to "a" in fun3() may be or may be not visible 
to the caller

In case of fun3() we have ambiguous behaviour, depending on the 
body of the function.

Am I right?
Is that intentional?


More information about the Digitalmars-d-learn mailing list