4 ms·
I have been contributing to the strange cousin of the macro which is the notion of inline DSL fragment. https://github.com/ngn/coffee-subscript https://github.c
by shaunxcode 14y ago
I have been contributing to the strange cousin of the macro which is the notion of inline DSL fragment. https://github.com/ngn/coffee-subscript https://github.com/ngn/coffee-subscript In essence you get latex looking (\dsl) syntax to enter what ever DSL (which is just a standard node module). So this could be something as simple as an annotation style approach in which you consume the next chunk of coffee-script and simply wrap it - or something more involved like an entirely different language (this originally stemmed from the desire to have inline APL ala https://github.com/ngn/apl https://github.com/ngn/apl - which provides \apl and \apl.fn respectively).
http://github.com/shaunxcode/jsedn http://github.com/shaunxcode/jsedn and http://github.com/shaunxcode/swedn http://github.com/shaunxcode/swedn also work currently. Right now they are naive e.g they just emit a call to parse at runtime, when I get the time they will actually be more clever and, well, actually compile at compile time hah.
Recently I have been toying with adding type annotations so I can easily port a code base to typescript but have them be entirely ignored by coffee.
One side note is that we have discussed adding support for sweetjs as right now these are definitely DSL hooks and not hygenic macros. In fact I would go so far as to call these toothless macros e.g. it is up to you to chew the food (parse) and swallow it (emit valid js).