3 ms·
The first time I saw `it` in a similar construction was in Arc language's aif macro: (mac aif (expr . body) `(let it ,expr (if
by dchest 8y ago
The first time I saw `it` in a similar construction was in Arc language's aif macro:
(mac aif (expr . body)
`(let it ,expr
(if it
,@(if (cddr body)
`(,(car body) (aif ,@(cdr body)))
body))))
HN uses it quite a lot, e.g.:
(defop logout req
(aif (get-user req)
(do (logout-user it)
(pr "Logged out."))
(pr "You were not logged in.")))
- bjoli 8y agoAnaphoric macros have been used in common lisp since forever.
- dchest 8y agoThanks for the name! Here's a wikipedia article about them: https://en.wikipedia.org/wiki/Anaphoric_macro https://en.wikipedia.org/wiki/Anaphoric_macro
- emidln 8y agoPGs On Lisp details these macros from common lisp. I'm unsure how old they are.
- zbentley 8y agoIs it a language feature in that example, or a user defined function/macro? It looks like the latter, but I don't speak Lisp, so I may be wrong.
- icebraining 8y agoThe latter.
- dchest 8y agoActually, it can be called a language feature, since it's the macro is defined in arc.arc, the arc lib.