front evaluated multiple time with joiner depending on where extra arg given

Timothee Cour thelastmammoth at gmail.com
Tue Oct 22 16:36:39 PDT 2013


Does that make sense? feature or bug?

void main(){
  import std.algorithm;
  import std.array;
  {
    int counter=0;
    auto b=[1,2,3].map!(a=>{counter++; return [a];}()).joiner([0]).array;
    assert(counter==3);
  }
  {
    int counter=0;
    auto b=[1,2,3].map!(a=>{counter++; return [a];}()).joiner().array;
    assert(counter==6);//why 6 whereas other one was 3?
  }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20131022/a0883233/attachment.html>


More information about the Digitalmars-d-learn mailing list