On Friday, 16 September 2016 at 17:55:59 UTC, Jonathan M Davis
wrote:
On Friday, September 16, 2016 17:22:41 Antonio Corbi via
Digitalmars-d-learn wrote:
Shouldn't it be mentioned then in the docs that this works for
statically sized arrays and that in that case it copies
contents?
Well, I confess that I don't know why you would ever have
thought that
s = t;
wouldn't work. The only mutable types that can't be assigned to
like this are the ones that have disabled assignment or copying
(which would only be certain structs).
And I thought that the spec made it clear that static arrays
were value types, in which case the behavior of
s = t;
should be obvious. So, I would have thought that it would be
clear enough as-is, but clearly, it wasn't for you. So, I don't
know. We do want the spec to be clear, but it would also be bad
to add a bunch of redundant information in an attempt to be
clearer. I'd have to go digging through the spec though to give
any concrete suggestions on how to improve this though.
- Jonathan M Davis
Hi Jonathan!
Probably this entry in https://dlang.org/spec/arrays.html#usage
confused me a bit.
int[3] s;
...
s = ...; // error, since s is a compiled in static
// reference to an array.
Thanks for your help!
Antonio