4 ms·
sweetjs was a good idea, but I've found it hard to use, or rather..it's not the using part that's hard, but writing your own macro. sweetjs has this hygienic t
by lightblade 13y ago
sweetjs was a good idea, but I've found it hard to use, or rather..it's not the using part that's hard, but writing your own macro.
sweetjs has this hygienic thing that renames identifiers. To prevent it from renaming, there are many hoops that you have to jump through to prevent it.
sweetjs introduces of a lot of new concepts. These concepts are not as easy to understand as the ones in C. The macros are certainly more powerful. It's just that assuming it's C-like macro will give you the wrong kind of expectation with sweetjs.
- aaronem 13y agoOf course! These aren't C "macros"; they're Lisp macros, which is a wholly different, and far more valuable and reliable, proposition. Granted, I'm not sure how much I like the idea of a macro system which finds macro instances by string-matching the source it's given. But in a non-homoiconic language, I'm not sure anything else is feasible, and I can easily see how something like this could improve Angular.js's dependency injection, for example.
- taejo 13y agoUnhygienic macros aren't a C-ism: hygiene was an innovation (I think originally in Scheme). Ordinary Common Lisp macros are unhygienic.
- aaronem 13y agoSo are sweet.js macros, or else they wouldn't need to have reimplemented GENSYM. But I get the impression (parent (parent)) had sweet.js macros mixed up with C-style string-replacement "macros", which was what prompted my comment.
- mnemonik 13y agoSweet.js is hygienic but you can choose to be unhygienic if you want. It is the best of both worlds. http://sweetjs.org/#getting_dirty__breaking_hygiene http://sweetjs.org/#getting_dirty__breaking_hygiene