Why change = operator to += for newDelegate() ?

samaursa

14-02-2011 19:50:16

I am sure you have a good reason to do this, but operator overloading like that (which in this context does not make sense to me) is bad imo. I really like using MyGUI and I thought I'd voice my opinion regarding this. I believe the original operator = was just fine to begin with. In fact, I would like to call a function instead of an overloaded operator.

I may not be aware of the circumstances that led to this deprecation in which case a short explanation would be welcome. :D

Altren

14-02-2011 20:13:17

The reason of changing '=' to '+=' was switching from delegates to multidelegates. In delegate operator= mean use new delegate instead of old one (if any was used). operator += mean that you can use several delegates for any event (and -= to remove it). Also one of the reasons of such syntax it is same as delegates in C#.
Do you think that we should add function, that do same thing as operator +=.

samaursa

14-02-2011 20:34:18

Ah, multidelegates puts the choice into perspective.

Do you think that we should add function, that do same thing as operator +=.

I personally would really like that and use that instead of overloaded operators. I would more than welcome the addition of functions that do the same as overloaded operators which I believe would avoid confusion for everyone when they look at the code after a while and don't remember what += or -= does.