digitalmars.D.bugs - [Issue 7015] New: ^^ and ^^= vector operations
- d-bugmail puremagic.com (24/24) Nov 25 2011 http://d.puremagic.com/issues/show_bug.cgi?id=7015
- d-bugmail puremagic.com (10/10) Dec 10 2011 http://d.puremagic.com/issues/show_bug.cgi?id=7015
- d-bugmail puremagic.com (27/28) Dec 10 2011 http://d.puremagic.com/issues/show_bug.cgi?id=7015
- d-bugmail puremagic.com (18/18) Dec 10 2011 http://d.puremagic.com/issues/show_bug.cgi?id=7015
http://d.puremagic.com/issues/show_bug.cgi?id=7015
Summary: ^^ and ^^= vector operations
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: druntime
AssignedTo: nobody puremagic.com
ReportedBy: bearophile_hugs eml.cc
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
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 25 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7015
Stewart Gordon <smjg iname.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |smjg iname.com
How, exactly, does this differ from (marked fixed) issue 3661?
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 10 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7015How, 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? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 10 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7015
Stewart Gordon <smjg iname.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic, spec
Summary|^^ and ^^= vector |Allow vector operations
|operations |into newly declared array
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.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 10 2011









d-bugmail puremagic.com 