http://d.puremagic.com/issues/show_bug.cgi?id=11082
--- Comment #7 from [email protected] 2013-09-21 13:18:09 PDT --- (In reply to comment #6) > But is it worth doing for every other algorithm, and every container type? Probably not. But I think it's worth doing for a small subset of algorithms, as std.algorithm.join. Regarding containers, fixed sized arrays are built-ins, and they are supposed to be used often, so it's not unreasonable to handle them differently/better than library-defined containers. > You have to do: > > data.map!((ref a => a[])).join.writeln; > > Unfortunately shorthand lambdas and unaryFun default to pass-by-value, so you > get a stack copy of your static array, which you then slice just as it goes > out > of scope. DMD has to give a compile-time error for such situation. I think there's an enhancement request opened on that. Joining a sequence of fixed-size arrays is a commonly done operation (in my code), and that map+join code is bug-prone. Your code too has a small mistake: import std.algorithm: join; import std.stdio, std.algorithm; void main() { int[2][] data = [[1, 2]]; data.map!((ref a) => a[]).join.writeln; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
