What's the deal with "Warning: explicit element-wise assignment..."

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 29 11:31:01 PDT 2014


On Tue, 29 Apr 2014 14:08:59 -0400, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Steven Schveighoffer:
>> On Tue, 15 Apr 2014 13:46:11 -0400, bearophile
>>> What do you think are the reasons I suggested the enhancement for?
>>
>> To make people write code the way you like? :)
>>
>> Honestly, it's like you require someone to call a function like:
>>
>> T foo(T)(T t){return t;}
>>
>> Just so you can see the foo there. I understand the idea, but the  
>> result is not logical, just superficial.
>
> Issue 7444 allows to tell apart the two very different operations of  
> this code, that look the same:
>
>
> void main() {
>      int[][3] x;
>      int[]    y;
>      int[]    z;
>
>      x[] = z; // copies just the z pointer
>      y[] = z; // copies the elements in z
> }

x[] = z[]; // copies just the z pointer
y[] = z[]; // copies the elements in z.

The problem is that the brackets don't affect the operation, just the type  
of the expression. To ascribe more logical meaning results in rather  
awkward and incorrect assumptions.

-Steve


More information about the Digitalmars-d mailing list