[Issue 7444] Require [] for array copies too
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Feb 9 05:33:55 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7444
--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> 2012-02-09 05:33:52 PST ---
(In reply to comment #1)
> While I agree that the syntax should be enforced more strictly in general, I
> still completely disagree with requiring [] on static array copies. Static
> arrays are value types of fixed size, and should be treated as such. Requiring
> [] is just wrong.
>
> void foo(int[4] x){}
> void foo(int[] y){}
>
> void main(){
> int[4] x, y;
> struct S{int[4] x;}
> S a, b;
> x = y;
> a = b; // why should this work if the above does not?
> foo(x); // copies, you want this to be an error
> foo(x[]); // calls the other overload, does not copy
> }
I completely agree with Timon.
When x and y are declared with same type T, x = y is identity assignment, and
it is valid syntax even if T is static array type.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list