operator overloading proposal
kevinb at khanacademy.org
Sun May 8 00:24:50 UTC 2016
I've been working on implementing operator overloading and would like to
submit a proposal.
I think operator overloading would be a useful addition to the language.
In particular I think it would be useful for defining operations on common
mathematical object types such as complex numbers, vectors, matrices, and
I've create a working prototype that consists of:
- babel plugin that rewrites operators as function calls
- a polyfill which defines these functions and which call the correct
argument-specific function based on the arguments' prototypes
- Function.defineOperator which can be used to define which function an
operator should use for the specified types
- "use overloading" directive which allows users to opt-in
More details can be found at
The babel plugin can be found at
I also have a demo project at
The design was inspired by some of the slides from
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss