Andrei Alexandrescu wrote:
> * Encode operators by compile-time strings. For example, instead of the
> plethora of opAdd, opMul, ..., we'd have this:
> 
> T opBinary(string op)(T rhs) { ... }
> 
> The string is "+", "*", etc. We need to design what happens with
> read-modify-write operators like "+=" (should they be dispatch to a
> different function? etc.) and also what happens with index-and-modify
> operators like "[]=", "[]+=" etc. Should we go with proxies? Absorb them
> in opBinary? Define another dedicated method? etc.
> 

Index-and-modify operators shouldn't exist.  That's the wrong place for it.

Indexing operators act like properties.  It is up to the types that they
get and set to define the opXxxAssign overloads.

http://www.digitalmars.com/d/archives/digitalmars/D/A_possible_solution_for_the_opIndexXxxAssign_morass_98143.html#N98176

- Chad

Reply via email to