Search code examples
clojurecommon-lisps-expressionreader-macro

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


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 in simple terms?


Solution

  • 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: