www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7015] New: ^^ and ^^= vector operations

reply d-bugmail puremagic.com writes:
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


--- Comment #0 from bearophile_hugs eml.cc 2011-11-25 17:05:12 PST ---
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
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7015


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com


--- Comment #1 from Stewart Gordon <smjg iname.com> 2011-12-10 08:58:48 PST ---
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
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7015



--- Comment #2 from bearophile_hugs eml.cc 2011-12-10 10:36:52 PST ---
(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? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 10 2011
prev sibling parent d-bugmail puremagic.com writes:
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


--- Comment #3 from Stewart Gordon <smjg iname.com> 2011-12-10 17:18:34 PST ---
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