5 ms·
> You can implement a macro system in 30 lines of Lisp. All you need is read, and it’s easy. The linked pastebin isn't a macro system. It's merely a macroexpan
by akkartik 15y ago
> You can implement a macro system in 30 lines of Lisp. All you need is read, and it’s easy.
The linked pastebin isn't a macro system. It's merely a macroexpansion system, it needs to be evaluated. And it's not as simple as merely wrapping it in 'eval' because of subtleties in getting at the right lexical scope.
More generally, no fair claiming macros are easy because you managed to build them atop a lisp. You're using all the things other comments here refer to; claiming it's all 'read' is disingenuous.
I'm still[1] looking for a straightforward non-lisp implementation of real macros. The clearest I've been able to come up with is an fexpr-based interpreter: http://github.com/akkartik/wart http://github.com/akkartik/wart
[1] From nearly 2 years ago: http://news.ycombinator.com/item?id=1468345 http://news.ycombinator.com/item?id=1468345
- noblethrasher 15y agohttp://nemerle.org/Macros http://nemerle.org/Macros
- wes-exp 15y agoThe currently front-paged Julia claims to have macros in a non-lisp. https://news.ycombinator.com/item?id=3606380 https://news.ycombinator.com/item?id=3606380
- calibraxis 15y agoAnd there's Dave Moon's PLOT (Programming Language for Old Timers). http://news.ycombinator.com/item?id=537652 http://news.ycombinator.com/item?id=537652 With the interesting critique that "objects" are better than s-expressions for representing sourcecode. (BTW, Moon did a lot of work on Lisp.) I've too thought that s-expressions don't necessarily contain as much information as you'd want. Using Rich Hickey's word from "Simple Made Easy", maybe they're used to "complect" visual presentation and internal representation. Then again, there's metadata...
- akkartik 15y agoThanks for those links (wes-exp as well). But I meant a non-lisp implementation of lisp macros. Obviously common lisp and racket qualify, but I'd love to see an implementation that's as simple as possible without needing to be production-quality.
- akkartik 15y agoAlso, is PLOT actually available? I think I must have come across it 3 times and searched for a download link without luck.
- calibraxis 15y agoLast I heard, it's not — Moon didn't think his work was high enough quality to release, and invited others to do so.