> Is it possible that + can be overloaded, but += cannot (but is derived from > +)?
Yes, that is right. += is just sugar. There has been talk to make += stand on its own. > My context is this: > > I want to define some type, say `mytype` and allow the operation > A = mytype() > A[i] += B > where i is some index, B is some value. > > But I do *not* want to allow something like > A = A + B > > At the moment, I just overload setindex!, but then I need to use A[i] = B > which reads all wrong. I don't quite understand. A[i] += B gets translated to A[i] = A[i] + B So you need to define both getindex and setindex! for A, and + needs to be defined for the elements of A & B. Then it should work.
