How does Lisp let you redefine the language itself?

后端 未结 7 499
心在旅途
心在旅途 2020-12-22 20:23

I\'ve heard that Lisp lets you redefine the language itself, and I have tried to research it, but there is no clear explanation anywhere. Does anyone have a simple example?<

7条回答
  •  再見小時候
    2020-12-22 21:16

    Cool example at http://www.cs.colorado.edu/~ralex/papers/PDF/X-expressions.pdf

    reader macros define X-expressions to coexist with S-expressions, e.g.,

    ? (cx ) 
    62
    

    plain vanilla Common Lisp at http://www.AgentSheets.com/lisp/XMLisp/XMLisp.lisp ...

    (eval-when (:compile-toplevel :load-toplevel :execute)
      (when (and (not (boundp '*Non-XMLISP-Readtable*)) (get-macro-character #\<))
        (warn "~%XMLisp: The current *readtable* already contains a #/< reader function: ~A" (get-macro-character #\<))))
    

    ... of course the XML parser is not so simple but hooking it into the lisp reader is.

提交回复
热议问题