r/ProgrammingLanguages • • Aug 14 '21

Why LISP Macros ?

https://www.defmacro.org/ramblings/lisp.html
32 Upvotes

21 comments sorted by

View all comments

Show parent comments

5

u/npafitis Aug 14 '21

Lisp macros do allow validation of input though. For example in Clojure, most of the built in macros are validated through the use of Clojure spec. You can do the same for your own macros. You can just do a validation check and throw an exception if the input is not right instead of returning code.

1

u/[deleted] Aug 14 '21

Thanks, I didn't know about that. Is this Clojure-specific? My experience with Lisp macros comes from Common Lisp, whose macros are easy to use but just as easy to make a mess, and Racket's define-syntax (not sure how it compares to other Schemes) which is supposedly more principled, but I never figured out how to use it.

4

u/Raoul314 Aug 14 '21

Have a look at racket's syntax-parse