I'm trying to return a reference to a slice of an array , but am getting the following compile-time error (where the offending line is in slice
test.chpl:9: error: illegal expression to return by ref
Returning the full array works fine, as does taking a reference to a slice in the main program.
Is there a correct way to return a ref to a slice? Thanks in advance!
record R {
var A : [0.. #10] int;
proc full() ref {
return A;
}
proc slice() ref {
return A[0.. #5];
}
}
var r : R;
ref x1 = r.full();
ref x2 = r.slice();
ref x3 = x1[0.. #5];
Just for completeness :
chpl Version 1.16.0 pre-release (2659cc6)
ref
return intent). That's an interesting difference with return from aproc
.... – Confiteor