codalien/operator-overloading-js

Use Python names

piranna opened this issue · 5 comments

Use the Python names for operator overloading (mostly double underscore both at beggining and end of the function) and if possible the same behaviour.

Ok, nice, cool idea.

I think there is a guideline for underscore before and after in JavaScript, let me get hold of that, and post the findings here. :)

We can have support for both old ones and new python style upto some versions and mark old ones deprecated such that upgrades does not break legacy code.

I think there is a guideline for underscore before and after in JavaScript, let me get hold of that, and post the findings here. :)

I don't know, but it could be cool, yes :-)

We can have support for both old ones and new python style upto some versions and mark old ones deprecated such that upgrades does not break legacy code.

Good idea :-D

Also if having both names, you could set on the new ones this as the lval, since it's how Python does it and somewhat makes more sense... Why is it currently being handled as rval?

Why not just the operator itself?

 this['+'] = function() { ... }
 this.__plus = function() {...}

Yeat, the operator itself is better than Python names. Adobe's ExtendScript also uses that.