3 ms·
> they aren’t just simply quoted templates how is that related to Lisp? Is code generation in Lisp limited to 'quoted templates'?
by lispm 7y ago
> they aren’t just simply quoted templates
how is that related to Lisp? Is code generation in Lisp limited to 'quoted templates'?
- seanmcdirmid 7y agoIt is if you want ahead of time compilation to work on your generated code. People often confuse macros with full programmatic code generation, but they aren’t equivalent at all, of course.
- lispm 7y agoHow is that possible, given that macros are arbitrary Lisp procedures, which are transforming arbitrary input expressions (and world state) to output expressions (and new world state)? Also given that code generation is not limited to macros in Lisp. Any function can generate code and hand it over to the embedded AOT compiler.
- seanmcdirmid 7y agoI’m talking about the quoting inside to implement macros, they don’t allow for generalized run-time code generation. An embedded AOT compiler is compiling code at run-time, which isn’t allowed without writable code pages (which similarly makes the JIT disallowed as well).
- deleted 7y ago[deleted]
- lispm 7y agoSorry, I still don't understand. What do you mean by quoting vs. generalized code generation? In Lisp the macro can be a procedure, which takes expressions and then uses an arbitrary computation to generate new expressions. Using a quoting mechanism and code templates is fully optional.
- seanmcdirmid 7y agoIt can be, but generally isn’t as most macros don’t require generalized code generation, so quoting works just fine. Going back to the first comment I was replying to: > (In one case, I knew an experienced C# programmer to build and compile an expression at run-time using LambdaExpression [1]. It takes about 10 times as many lines to achieve the same thing, and you have to write in a style that looks nothing at all like a normal function, so in practice nobody ever does this. In contrast, the way to accomplish this in Lisp takes one character, and the code looks identical to a normal function, so it's not unheard of.) I assume they mean that they didn’t need to manipulate expressions in a general way because what they wanted was a simple macro that lisp supports with nice template/quote syntax, whereas C# doesn’t support macros at all but you can do something hacky with general run-time code generation.