In Lisp, code is data. What benefit does that provide?

前端 未结 4 591
遥遥无期
遥遥无期 2020-12-13 14:38

In Lisp, any program\'s code is actually a valid data structure. For example, this adds one and two together, but it\'s also a list of three items.

(+ 1 2)
<         


        
4条回答
  •  时光取名叫无心
    2020-12-13 14:57

    My favorite example... In college some friends of mine were writing a compiler in Lisp. So all their data structures including the parse tree was lisp s-expressions. When it was time to implement their code generation phase, they simply executed their parse tree.

提交回复
热议问题