http://d.puremagic.com/issues/show_bug.cgi?id=11082



--- Comment #6 from Peter Alexander <[email protected]> 2013-09-21 
11:36:14 PDT ---
(In reply to comment #5)
> (In reply to comment #4)
> 
> > You'd have to special case algorithms to handle them, because
> > they violate the range API by their very nature.
> 
> Right, I am asking for a specialization of join. It's worth doing.

But is it worth doing for every other algorithm, and every container type? If
not, why not? If so, I'd say that's too much to ask.


> > And it's trivial enough to
> > slice static arrays - even when they're inside a dynamic array -
> 
> This code is buggy:
> 
> import std.algorithm: join;
> import std.stdio, std.algorithm;
> void main() {
>     int[2][] data = [[1, 2]];
>     data.map!q{ a[] }.join.writeln;
> }

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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to