codalien / operator-overloading-js

Simple Operator overloading library for JS.
160 stars 26 forks source link

Use Python names #13

Open piranna opened 9 years ago

piranna commented 9 years ago

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

kushal-likhi commented 9 years ago

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.

piranna commented 9 years ago

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

piranna commented 9 years ago

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?

mohsen1 commented 9 years ago

Why not just the operator itself?

 this['+'] = function() { ... }
 this.__plus = function() {...}
xmedeko commented 4 years ago

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