On Thursday, 8 May 2014 at 21:38:12 UTC, Andrei Alexandrescu wrote:
int fun(int[] a) { auto before = format("Before: %s", a); foreach (ref e; a) ++e; auto after = format("After: %s", a); writeln(before, "\n--->\n", after); }*ouch*
You might think that's bad, but there's nothing in that example that is specific to formatting; that kind of behavior can happen with any lazy range taking input by ref. (I guess that's one drawback of providing functional programming without immutability?) To be clear, I'm not saying that the idea was to make the existing format function lazy, break existing code and surprise people with that change in semantics. format() can be an eager wrapper for the new lazy functionality. And eagerness/laziness should be part of the specification IMO, even more than asymptotic complexity should be part of the STL spec, since (bug > performance bug).
