Live data from Hacker News

Lisp Macros, Delayed Evaluation and the Evolution of Smalltalk

blog.metaobject.com

101–110 of 114 posts

Re: Lisp Macros, Delayed Evaluation and the Evolution of Smalltalk

#101
post #99

Earlier quoted context omitted.

The sequence of events you describe is a thing that functions do not do at run time: they do not operate on pieces of syntax. Macro expansion time is a different series of events than run time. Macros operate on pieces of program syntax, not on anything from run time. Everyone jumped on it, as production lisps don't implement macros this way. … This is about mental models, not implementation details It looks to me li…

I'm not confused, and nothing I'm talking about is novel, eg: http://matt.might.net/articles/metacircular-evaluation-and-f... SICP is a great way to learn lisp and learning macros by extending the evaluator is a natural progression. I don't care how many lisp experts are "correcting" me on the way it works in the real world, because: a) I actually do understand how they're implemented in existing production lisps. No…

"Macros" and "first-class macros" are different things. The latter are essentially fexprs.

I'm not sure why you continue to insist that responses to your comments are just about how macros happen to be implemented in Common Lisp.

Re: Lisp Macros, Delayed Evaluation and the Evolution of Smalltalk

#102
post #99

Earlier quoted context omitted.

The sequence of events you describe is a thing that functions do not do at run time: they do not operate on pieces of syntax. Macro expansion time is a different series of events than run time. Macros operate on pieces of program syntax, not on anything from run time. Everyone jumped on it, as production lisps don't implement macros this way. … This is about mental models, not implementation details It looks to me li…

I'm not confused, and nothing I'm talking about is novel, eg: http://matt.might.net/articles/metacircular-evaluation-and-f... SICP is a great way to learn lisp and learning macros by extending the evaluator is a natural progression. I don't care how many lisp experts are "correcting" me on the way it works in the real world, because: a) I actually do understand how they're implemented in existing production lisps. No…

You can't teach "macros": you have to choose and teach a specific macro system (at a time), whose behavior is linked to the way(s) it is implemented. Each has its own mental models; there is no single mental model for all macros everywhere.

Re: Lisp Macros, Delayed Evaluation and the Evolution of Smalltalk

#103

Earlier quoted context omitted.

I'm not confused, and nothing I'm talking about is novel, eg: http://matt.might.net/articles/metacircular-evaluation-and-f... SICP is a great way to learn lisp and learning macros by extending the evaluator is a natural progression. I don't care how many lisp experts are "correcting" me on the way it works in the real world, because: a) I actually do understand how they're implemented in existing production lisps. No…

You can't teach "macros": you have to choose and teach a specific macro system (at a time), whose behavior is linked to the way(s) it is implemented. Each has its own mental models; there is no single mental model for all macros everywhere.

Which is just as effective an argument against the entire of SICP. In a real lisp, a (list? ) doesn't return true. You can't dig around inside a closure and walk the entire environment which is made up of a list of pairs.

But the point of a toy model is that you can read an implementation, build your own, reason about it and send code through it with little difficulty.

Once you've built eval and sent real programs through it, it's not a big jump from that to understanding how real tools work, which can generally be done incrementally.

That was certainly my lisp journey, and that includes macros (which were a separate step). After implementing them in eval, learning how they're in the real world was about as challenging as reading a restaurant menu.

Re: Lisp Macros, Delayed Evaluation and the Evolution of Smalltalk

#104

Earlier quoted context omitted.

You can't teach "macros": you have to choose and teach a specific macro system (at a time), whose behavior is linked to the way(s) it is implemented. Each has its own mental models; there is no single mental model for all macros everywhere.

Which is just as effective an argument against the entire of SICP. In a real lisp, a (list? ) doesn't return true. You can't dig around inside a closure and walk the entire environment which is made up of a list of pairs. But the point of a toy model is that you can read an implementation, build your own, reason about it and send code through it with little difficulty. Once you've built eval and sent real programs th…

[deleted]

Re: Lisp Macros, Delayed Evaluation and the Evolution of Smalltalk

#105
post #99

Earlier quoted context omitted.

The sequence of events you describe is a thing that functions do not do at run time: they do not operate on pieces of syntax. Macro expansion time is a different series of events than run time. Macros operate on pieces of program syntax, not on anything from run time. Everyone jumped on it, as production lisps don't implement macros this way. … This is about mental models, not implementation details It looks to me li…

I'm not confused, and nothing I'm talking about is novel, eg: http://matt.might.net/articles/metacircular-evaluation-and-f... SICP is a great way to learn lisp and learning macros by extending the evaluator is a natural progression. I don't care how many lisp experts are "correcting" me on the way it works in the real world, because: a) I actually do understand how they're implemented in existing production lisps. No…

> SICP is a great way to learn lisp

SICP is a book for beginner computer science students, with a focus on functional programming as base.

As a Lisp book it's not really good, since it covers only very little actual Lisp and uses only a core Scheme language.

There is literally nothing about macros in SICP. They are mentioned only in a few places (for example it is mentioned that DELAY would be implemented by a macro).

> The smug lisp weenie trope exists for a reason, and it's that the lisp community is too busy falling over themselves to prove how smart they are with arcane knowledge to give a shit about the experience beginners face

Since you ignore the large amount of literature, teaching & research on macros in the Lisp community, what you write is rather strange. Surprise: people teaching Lisp in the 60s already 'gave a shit about the experience beginners face'.

> I have an opinion on how best to teach macros. Maybe I'm wrong. Maybe it's not a good idea to extend SICP with macros, or maybe there's a better way, and I'd love to hear arguments in those directions. But correcting it by explaining how they're implemented in CL is absolutely baffling to me.

Lisp teachers usually taught macros in context of actual Lisp languages and actual usage examples. Personally I prefer that as a first approach, over trying to explain how to extend a toy implementation with some homebrew macro implementation.

Re: Lisp Macros, Delayed Evaluation and the Evolution of Smalltalk

#106
post #97

Earlier quoted context omitted.

In conclusion, it is definitely not working like a run-time function with different evaluation order.

In conclusion, it's working exactly as I laid it out in my original post: fn: (a b c) => (call a (eval b) (eval c)) mac: (a b c) => (eval (call a b c)) Everyone jumped on it, as production lisps don't implement macros this way. But it's the natural way to implement them in a SICP style metacircular evaluator, and a good way to learn them. This is about mental models, not implementation details. And in my opinion this…

> Everyone jumped on it, as production lisps don't implement macros this way. But it's the natural way to implement them in a SICP style metacircular evaluator, and a good way to learn them.

I don't think it is overly useful to explain people how to extend a SICP style metacircular evaluator with some custom macro system. It's often a part of the Lisp journey, but not something I would recommend for basic Lisp teaching.

If I want people to program in Lisp, I give them a real Lisp and teach them how to program with it.

> This is about mental models

Sure, but you are teaching them the wrong mental models (macros tied to an evaluator), while I would focus on the model of general code transformations and the tools to make effective use of them.

> And in my opinion this thread is full of experts who have forgotten what it's like to not understand how macros work.

Not sure who you talk about, but I have been explaining macros to people already in the 80s.

Re: Lisp Macros, Delayed Evaluation and the Evolution of Smalltalk

#107
post #105

Earlier quoted context omitted.

I'm not confused, and nothing I'm talking about is novel, eg: http://matt.might.net/articles/metacircular-evaluation-and-f... SICP is a great way to learn lisp and learning macros by extending the evaluator is a natural progression. I don't care how many lisp experts are "correcting" me on the way it works in the real world, because: a) I actually do understand how they're implemented in existing production lisps. No…

> SICP is a great way to learn lisp SICP is a book for beginner computer science students, with a focus on functional programming as base. As a Lisp book it's not really good, since it covers only very little actual Lisp and uses only a core Scheme language. There is literally nothing about macros in SICP. They are mentioned only in a few places (for example it is mentioned that DELAY would be implemented by a macro)…

That's fine; I prefer the latter. Maybe I'm wrong. But if I am, it's not because I don't understand how macros are actually implemented in the real world, as everyone in this massive thread seems to assume.

I regret my initial comment, which was written in haste. Had I known the sheer volume of people that would jump out the woodwork to demonstrate their superior technical knowledge while avoiding the argument I was actually making, I'd have been a lot more careful about what I was trying to communicate (or more likely not have bothered, which would have saved us all a lot of time).

That is where the "smug lisp weenie" trope comes from, and it's real. I don't know what it is specifically about lisp that brings it out; I can't imagine having this discussion about C#, TCL or SQL.

Re: Lisp Macros, Delayed Evaluation and the Evolution of Smalltalk

#108
post #105

Earlier quoted context omitted.

> SICP is a great way to learn lisp SICP is a book for beginner computer science students, with a focus on functional programming as base. As a Lisp book it's not really good, since it covers only very little actual Lisp and uses only a core Scheme language. There is literally nothing about macros in SICP. They are mentioned only in a few places (for example it is mentioned that DELAY would be implemented by a macro)…

That's fine; I prefer the latter. Maybe I'm wrong. But if I am, it's not because I don't understand how macros are actually implemented in the real world, as everyone in this massive thread seems to assume. I regret my initial comment, which was written in haste. Had I known the sheer volume of people that would jump out the woodwork to demonstrate their superior technical knowledge while avoiding the argument I was…

People with a bunch of Lisp experience have responded to what you wrote and disagreed. That's all.

Re: Lisp Macros, Delayed Evaluation and the Evolution of Smalltalk

#109
post #108

Earlier quoted context omitted.

That's fine; I prefer the latter. Maybe I'm wrong. But if I am, it's not because I don't understand how macros are actually implemented in the real world, as everyone in this massive thread seems to assume. I regret my initial comment, which was written in haste. Had I known the sheer volume of people that would jump out the woodwork to demonstrate their superior technical knowledge while avoiding the argument I was…

People with a bunch of Lisp experience have responded to what you wrote and disagreed. That's all.

Like I said previously, I don't believe being an expert automatically makes you a good teacher. Based on the responses in this thread, I doubt anyone here is actually good at it.

Were I disagreeing technically, it would be a different matter and I'd have long ago hit the books to see where I fucked up. The combined lisp experience on this thread is at least an order of magnitude more than mine, and most of you are probably smarter than me to boot.

Re: Lisp Macros, Delayed Evaluation and the Evolution of Smalltalk

#110
post #108

Earlier quoted context omitted.

People with a bunch of Lisp experience have responded to what you wrote and disagreed. That's all.

Like I said previously, I don't believe being an expert automatically makes you a good teacher. Based on the responses in this thread, I doubt anyone here is actually good at it. Were I disagreeing technically, it would be a different matter and I'd have long ago hit the books to see where I fucked up. The combined lisp experience on this thread is at least an order of magnitude more than mine, and most of you are pr…

and I doubt your claim, that extending a meta-circular toy interpreter with some remotely macro-like feature will help any Lisp beginner to understand Lisp macros.

There is already a bunch of good material out there, teaching the use of Lisp macros for both beginners and for medium-level users. Advanced-level users will find a lot of teaching&research in the Scheme literature/...

Paul Graham himself has written a good and well-known book on it. it does a good job explaining macros and their use. It's called 'On Lisp' and there is no need to replicate its content here.

Now we have gone full circle, again.

Post reply on HN