A matter of inout
bearophile
bearophileHUGS at lycos.com
Fri Jul 27 08:53:11 PDT 2012
This program used to compile in DMD 2.059:
import std.stdio;
inout(T[]) forwardDifference(T)(inout(T[]) s, in int n) pure {
foreach (_; 0 .. n)
s[] -= s[1 .. $];
return s[0 .. $-n];
}
void main() {
immutable A = [90.5, 47, 58, 29, 22, 32, 55, 5, 55, 73.5];
foreach (level; 0 .. A.length)
writeln(forwardDifference(A.dup, level));
}
Now it gives:
test.d(5): Error: slice s[] is not mutable
test.d(12): Error: template instance
test.forwardDifference!(double) error instantiating
Is it a 2.060 regression (or it's caused by a bug fix)?
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list