While writing some D code that uses vectors and the desire to find distances among them, I'd like this vector operation to be supported: void main() { int[] a = [1, 2, 3]; int[] b = a[] ^^ 2; } DMD 2.057head gives: test.d(3): Error: Array operation a[] ^^ 2 not implemented
How, exactly, does this differ from (marked fixed) issue 3661?
(In reply to comment #1) > How, exactly, does this differ from (marked fixed) issue 3661? Thank you Stewart, you are right. Vector pow is already implemented: import std.math, std.stdio; void main() { int[3] a = [1, 2, 3]; int[3] b; b = a[] ^^ 2; writeln(b); a[] ^^= 2; writeln(a, " ", b); } So this is a: 1) A diagnostic bug, because the error message is misleading. 2) It shows a more general design problem with vector operations, because code like this too is refused with a similar error message: void main() { int[] a = [1, 2, 3]; int[] b = a[] + 2; } Vector ops require the memory needed to store the result to be already present. I don't know if this will change. What do you suggest to do with this bug report, to close it?
So the language currently doesn't allow vector ops into a newly declared array. So this is really two things: (a) as you say, a diagnostic bug, as the error message when you try to do it is bogus (b) a language feature request to allow this code I'm guessing (a) and (b) need to be filed as two separate issues. But meanwhile, I'm changing the summary line so that it at least makes sense.
(In reply to Stewart Gordon from comment #3) > So this is really two things: > (a) as you say, a diagnostic bug, as the error message when you try to do it > is bogus > (b) a language feature request to allow this code Maybe (b) is a duplicate of 2548
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17115 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB