What are the advantages of scheme macros?

后端 未结 3 1363
小蘑菇
小蘑菇 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-04 00:00

    Scheme macros preserve referential transparency.

    Quoting the "Guile Reference Manual" 6.10.2.2 Hygiene:

    syntax-rules macros (..) preserve referential transparency. When you read a macro definition, any free bindings in that macro are resolved relative to the macro definition; and when you read a macro instantiation, all free bindings in that expression are resolved relative to the expression.

    This property is sometimes known as hygiene, and it does aid in code cleanliness. In your macro definitions, you can feel free to introduce temporary variables, without worrying about inadvertently introducing bindings into the macro expansion.

    Standard scheme offers syntax-rules and syntax-case.

提交回复
热议问题