What are the advantages of scheme macros?

后端 未结 3 1361
小蘑菇
小蘑菇 2021-02-03 23:32

Why would anyone prefer Scheme macros over Common Lisp macros (and I genuinely want to know too, I\'m not trying to be a troll)?

My experience as a Lisp newb is that Com

3条回答
  •  星月不相逢
    2021-02-03 23:55

    Because they use a different, non-Scheme language, Scheme macros are less powerful than Common Lisp macros in the almost-formal sense: you can do arbitrary compile-time computation with them, but it's hairy and convoluted. It's a lot like the argument for not using set!: less-powerful set!free languages produces less buggy code in exchange for awkward handling of state. Any time you trade power for discipline, you are betting that you will be able to build more complex systems in the long run.

    That's the best argument I've seen for Scheme macros over Common Lisp ones: if you are building a complex language on top of Scheme, you are less likely to introduce subtle macro bugs if you stick with the standard macro system.

    Personally, I don't build big languages using macros, so I prefer Common Lisp macros. I find them much easier for small jobs and avoiding variable capture etc isn't a big deal on a small scale.

提交回复
热议问题