Two primary concerns: 1. JS uses proxies for a few similar hooks (like `foo["prop"]` and `foo()`) now. Python uses `__getattr__` and `__call__` for those, but JS doesn't use magic methods for those.
2. Performance is going to be much harder to ensure, especially if you can mutate the operator methods them after creation. Scala, Haskell, C++, and the like can get away with operator functions/methods without a perf cliff, since they assume the operator to never change. You don't have that luxury with JS symbols - they *can* change. This is no different than in Python, and it's part of why PyPy is much slower than JS. LuaJIT only handles them well because a) Lua is very simple to begin with, and b) it does highly sophisticated analysis not seen in any other runtime, engineered by one of the top JIT and assembly experts in the field. (See Luafun for an example of its abilities, including its source code.) On Thu, Jul 13, 2017, 23:56 Boris Cherny <bo...@performancejs.com> wrote: > > javascript operator-overloading is a solution in search of a problem. > > Why is JS different than languages that treat operators as methods, and > make heavy use of overloading (Scala, Haskell, ...)? There seem to be lots > of good use cases, same as in other languages. > > > On Jul 13, 2017, at 5:07 PM, es-discuss-requ...@mozilla.org wrote: > > > > Send es-discuss mailing list submissions to > > es-discuss@mozilla.org > > > > To subscribe or unsubscribe via the World Wide Web, visit > > https://mail.mozilla.org/listinfo/es-discuss > > or, via email, send a message with subject or body 'help' to > > es-discuss-requ...@mozilla.org > > > > You can reach the person managing the list at > > es-discuss-ow...@mozilla.org > > > > When replying, please edit your Subject line so it is more specific > > than "Re: Contents of es-discuss digest..." > > Today's Topics: > > > > 1. Operator overloading proposal (Keith Cirkel) > > 2. Re: Operator overloading proposal (kdex) > > 3. Re: Operator overloading proposal (Oriol _) > > 4. Re: Operator overloading proposal (kai zhu) > > <mime-attachment> > > <mime-attachment> > > <mime-attachment> > > <mime-attachment> > > _______________________________________________ > > es-discuss mailing list > > es-discuss@mozilla.org > > https://mail.mozilla.org/listinfo/es-discuss > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss