[Issue 12770] New: Array operation result assignment to static arrays is complicated
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon May 19 22:31:08 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12770
Issue ID: 12770
Summary: Array operation result assignment to static arrays is
complicated
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: turkeyman at gmail.com
I think this should work:
float[4] f(float[4] a)
{
return (-a[])[0..$];
}
Error: cannot implicitly convert expression ((-a[])[0..__dollar]) of type
float[] to float[4]
What I was actually trying to do, is perform array operations on static arrays.
I'd like to think this should work:
float[4] f(float[4] a)
{
return -a;
}
I tend not to think of static arrays like arrays, they're more like a discreet
object.
Requiring a[] causes a to become a dynamic array, and then it can't be assigned
back to a static array anymore. It all goes south for array operations on
static arrays with [].
At very least, this should probably work:
float[4] f(float[4] a)
{
return -a[];
}
--
More information about the Digitalmars-d-bugs
mailing list