4 ms·
Nice Lisp macro features your naive scheme lacks: - Lisp macros are expanded implicitly at compile-time so you don't have a big mess of temporary files; - Lis
by Hexstream 18y ago
Nice Lisp macro features your naive scheme lacks:
- Lisp macros are expanded implicitly at compile-time so you don't have a big mess of temporary files;
- Lisp macro calls look just like the built-in operators, unlike your proposed "python macros" where all your macro invocations are a string
- For all but the most trivial cases your string-based scheme will force you to use concatenation and it will really get ugly really fast. In contrast, with Lisp it's much easier to represent code as data. For example, (+ 1 2) is the code to add 1 and 2 while '(+ 1 2) is a list representing the code to add 1 and 2 and you can then interpolate that easily in the generated code
- And your example is really awesomely constrained, it works but it also doesn't really help with anything. With Lisp, the macro facility scales from trivial problems where the macro code fits in 4 lines to very complex ones where the macro code spans 4 files.
- gaius 18y agoThis is one reason I like Tcl, it's not far off Lisp in the sense that it's a "programmable programming language" and I can get away with using it at work because they think it's just fancy shell-script :-) For an example see http://wiki.tcl.tk/917 http://wiki.tcl.tk/917