import std.stdio;
void main() {
double[] foo = [1.0,2,3,4,5].dup;
double[] bar = [6.0,7,8,9,10].dup;
auto baz = foo[] + bar[]; //Error: Array operation foo[] + bar[] not implemented
}
Ideally, the compiler should create baz and put the result of foo[] + bar[] in this newly created array. If the goal of not allowing this behavior is to avoid hidden memory allocations, then a more informative error message should be displayed.
Comment #1 by smjg — 2008-12-31T10:24:03Z
This certainly ought to work. The memory allocation is no more 'hidden' than that involved in concatenation already is. So that isn't really a valid reason.
But the error message is poor whether you think it should be allowed or not.
Comment #2 by damianday — 2014-05-24T05:42:57Z
double[] foo = [1.0,2,3,4,5].dup;
double[] bar = [6.0,7,8,9,10].dup;
auto baz = foo[] ~ bar[];
This works fine now in 2.065
Comment #3 by john.loughran.colvin — 2015-07-30T17:11:23Z
This is a wontfix, not a fixed. Damian's example is different and AFAIK always worked.
Comment #4 by Jesse.K.Phillips+D — 2015-07-30T22:21:46Z
Since Damian closed this as fixed due to a different code example, I'm going to reopen as no D developer has said this won't get implemented.
Comment #5 by robert.schadek — 2024-12-13T17:49:14Z