Re[2]: Operators overriding

KOLANICH kolan_n at
Wed Dec 23 08:23:55 UTC 2015

I dislike this proposal.
1 It is not very good to limit overrideable operators to value classes.
2 It is not very good to have a lot of custom operators, it will break code readability and will allow more efficient obfuscration.
3 I think that most of binary non-assigning operators must return a new object and thats' why they should be not object methods, but the methods taking 2 (or more if chained!) objects and return the result usually of same type.
вторник, 22 декабря 2015г., 21:45 +03:00 от Sander Deryckere < sanderd17 at> :

>IMO, operator overloading is important and different enough to warrant a separate syntax.
>But the difficulty isn't in defining the operator, but in the ambiguous cases. Like what to do when there are 2 different types, how to make sure certain relations will stay correct, ...
>There's a nice presentation from Brendan Eich here:
>2015-12-18 21:24 GMT+01:00 KOLANICH  < kolan_n at > :
>>Hello. What do you think about overriding operators using proxies?
>>For example
>>function A(r=""){
>>return new Proxy(this,{operators:{"+":function(a,b){return new A(a.rep+"+"+b.rep);}}});
>>let a=new A("a"), b=new A("b");
>>let c=a+b;
>>es-discuss mailing list
>>es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list