Examples of what Lisp's macros can be used for

后端 未结 8 940
自闭症患者
自闭症患者 2020-12-24 05:56

I\'ve heard that Lisp\'s macro system is very powerful. However, I find it difficult to find some practical examples of what they can be used for; things that would be diffi

8条回答
  •  心在旅途
    2020-12-24 06:35

    Pick any "code generation tool". Read their examples. That's what it can do.

    Except you don't need to use a different programming language, put any macro-expansion code where the macro is used, run a separate command to build, or have extra text files sitting on your hard disk that are only of value to your compiler.

    For example, I believe reading the Cog example should be enough to make any Lisp programmer cry.

提交回复
热议问题