
Referential
Transparency
is Overrated
Didier Verna
Introduction
Scoping
Syntax
Extension
Symbol
Macros
Macros
Crash Course
Variable Capture
Variable Injection
Lexical channels
Conclusion
Why are macros useful?
CTMP, factoring, non-strict idioms etc
Will this work?
( defun i f n o t ( t e s t t hen e ls e )
( i f t e s t e lse t hen ) )
; ; ( i f n o t t ( e r r o r " Kaboum ! " ) ’ okay ) −> Kaboum!
This will
( defmacro i f n o t ( t e s t t hen e ls e )
( l i s t ( quote i f ) t e s t e lse then ) )
; ; ( i f n o t t ( e r r o r " Kaboum ! " ) ’ okay ) −> ( i f t ’ okay ( e r r o r " Kaboum ! " ) )
Even better, and even more better
( defmacro i f n o t ( t e s t t hen e ls e )
( l i s t ’ i f t e s t e l se th en ) )
( defmacro i f n o t ( t e s t t hen e ls e )
‘ ( i f , t e s t , el se , then ) )
44/54