www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2548] New: Array ops that return value to a new array should work.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2548

           Summary: Array ops that return value to a new array should work.
           Product: D
           Version: 2.022
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: dsimcha yahoo.com


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.


-- 
Dec 30 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2548


smjg iname.com changed:

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




------- Comment #1 from smjg iname.com  2008-12-31 10:24 -------
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.


-- 
Dec 31 2008