Hacker News new | past | comments | ask | show | jobs | submit login

I'm not the above poster but I think the power of macros is way overhyped and not nearly as strong as people claim. I see the claim of "you can write a macro to do it" for any imaginable feature all the time, but it is simply not true.

A recent example from personal use is continuations. Scheme has them as a first-class object. Common Lisp does not, but a common claim is that you can write macros to provide continuations. Some people have: there's "cl-cont" available on Quicklisp, which is a macro that will code-walk your functions to turn them into continuation-passing style and thus allow you to use continuations in those functions.

So that's great, right? Common Lisp now totally has continuations? Not at all. In order to get this feature, you need to wrap ahead of time (specifically, at compile time) the functions you want to be continuable, and all of their callers, in this macro. You cannot simply use a function that you've been given as part of a continuation, it had to have been compiled under this macro.

That's where the power of macros completely falls down and, in my opinion, gets completely overblown. Yes, your language is extendable, but your extensions are limited to computation and source-to-source transformation at compile time. You can't apply any of that power to already-existing artifacts.




> I see the claim of "you can write a macro to do it" for any imaginable feature all the time, but it is simply not true.

Which is not surprising. Actually nobody with a clue makes such a claim.

Still, Lisp macros have a wide variety of very useful applications.

> Yes, your language is extendable, but your extensions are limited to computation and source-to-source transformation at compile time.

Still quite useful. From relatively simple stuff which makes to code more readable to complex macros like ITERATE.


You'll note that I never said it was not useful, but rather it was not this powerful magic sauce that can do anything.

> Which is not surprising. Actually nobody with a clue makes such a claim.

Most Lisp books make this claim.


> Most Lisp books make this claim.

For sure not.


That's right; macros need a target language to expand to, and that target language needs to seamlessly inter-operate with the surroundings and with the forms that are inserted into it. Some semantics is simply not available without transforming the entire program in which the macro call occurs.


Yes, exactly my point. Macros are very powerful but not a magic sauce that makes Common Lisp infinitely extendable. Some things you actually need to change the underlying implementation for.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: