What advantage does common lisp reader macros have that Clojure does not have?

前端 未结 3 1319
情歌与酒
情歌与酒 2020-12-30 04:00

I have been using Clojure alot recently but I still don\'t understand what functionality I do not get that common lisp reader macros provide. Can explain explain this to me

3条回答
  •  清酒与你
    2020-12-30 04:47

    In short, reader macros provide you with the ability to redefine the programming language's syntax within some delimited context.

    For example, you could implement regular expression literals (e.g. #"pattern") yourself given reader macros. Without them, you would be forced to properly escape regular expressions in string literals passed to re-pattern.

    BTW, while there are no public Clojure APIs for modifying the reader, it's not impossible, as illustrated in these posts:

    • http://briancarper.net/blog/449/clojure-reader-macros
    • http://fulldisclojure.blogspot.com/2009/12/how-to-write-clojure-reader-macro.html

提交回复
热议问题