How would I extend the JavaScript language to support a new operator?

后端 未结 2 1807
轮回少年
轮回少年 2020-12-02 10:11

The answer to the question Is it possible to create custom operators in JavaScript? is not yet, but @Benjamin suggested that it would be p

2条回答
  •  被撕碎了的回忆
    2020-12-02 10:44

    As I said in the comments of your question, sweet.js doesn't support infix operators yet. You're free to fork sweet.js and add it yourself, or you're simply SOL.

    Honestly, it's not worth it to implement custom infix operators yet. Sweet.js is a well supported tool, and it's the only one I know of that tries to implement macros in JS. Adding custom infix operators with a custom preprocessor is probably not worth the gain you might have.

    That said, if you're working on this alone for non-professional work, do whatever you want...

    EDIT

    sweet.js does now support infix operators.

提交回复
热议问题