On Wed, 16 Apr 2014 04:05:57 -0400, Kagamin <s...@here.lot> wrote:

On Tuesday, 15 April 2014 at 15:59:31 UTC, Steven Schveighoffer wrote:
Requiring it simply adds unneeded hoops through which you must jump, the left hand side denotes the operation, the right hand side does not

Unfortunately, this particular operation is denoted by both sides.

Not really. The = operator (opAssign) is different from the [] = operator (opSliceAssign).

I actually am ignorant of how this works under the hood for slices, what triggers element-wise copy vs. assign. But for custom types, this is how you would have to do it I think.

Note -- it would be nice (and more consistent IMO) if arr[] = range worked identically to arr[] = arr.

Range or array, there are still two ways how it can work. The idea is to give the choice to programmer instead of the compiler.

But programmer cannot define new operators on slices.


Sorry, I had this wrong. The [] on the left hand side is actually part of the []= operator.

There's no such operator. You can assign fixed-size array without slice syntax.

Fixed size array is a different type with different semantics from slices. You cannot assign the pointer/length of a fixed-size array, so opAssign devolves to opSliceAssign.

-Steve

Reply via email to