3. “So, Ruby was a Lisp originally, in theory.
Let's call it MatzLisp from now on. ;-)”
-Matz
Friday, February 19, 2010
4. "Lisp isn't a language, it's a building material."
"the greatest single programming language ever
designed"
“OOP to me means only messaging, local
retention and protection and hiding of state-
process, and extreme late-binding of all things.
It can be done in Smalltalk and in Lisp. There
are possibly other systems in which this is
possible, but I'm not aware of them.”
-Alan Kay
Friday, February 19, 2010
6. As seen in Lisp since 1958
late binding
garbage collection
dynamic typing
if-then-else construct
function type
recursion
symbol type
Interactive development
Lisp Machines
...
Friday, February 19, 2010
7. As seen in Lisp since 1958
late binding
garbage collection
dynamic typing Scheme
if-then-else construct Common Lisp
function type Clojure
recursion Arc
symbol type NewLISP
Interactive development (JavaScript)
Lisp Machines
...
Friday, February 19, 2010
20. Why macros?
“Pascal is for building pyramids -- imposing,
breathtaking, static structures built by armies
pushing heavy blocks into place. Lisp is for building
organisms -- imposing, breathtaking, dynamic
structures built by squads fitting fluctuating myriads
of simpler organisms into place.
[...]
Invent and fit; have fits and reinvent!”
-from SICP foreword
Friday, February 19, 2010
21. Russian dolls
Lisp
user forms
special forms
kernel language
Friday, February 19, 2010
22. Russian dolls
language extensions
Lisp
user forms
special forms
kernel language
Friday, February 19, 2010
23. Functions vs Macros
Function
S-Expressions (f x) Values
Macro
S-Expressions (f x) S-Expressions
Friday, February 19, 2010
24. Functions vs Macros
S-Expressions
Macro
expansion (f x)
time
S-Expressions’
Compile /
execution (f’ x)
time
Values
Friday, February 19, 2010
25. The my-unless function
(defun my-unless (c ef et)
(if c et ef))
Friday, February 19, 2010
26. The my-unless function
(defun my-unless (c ef et)
(if c et ef))
(my-unless t 1 2) -> 2
(my-unless nil 1 2) -> 1
Friday, February 19, 2010
27. The my-unless function
(defun my-unless (c ef et)
(if c et ef))
(my-unless t 1 2) -> 2
(my-unless nil 1 2) -> 1
(my-unless t (print “test”) 1)
->”test”
1
Friday, February 19, 2010
28. The my-unless macro
(defmacro my-unless (c ef et)
(if c et ef))
Friday, February 19, 2010
29. The my-unless macro
(defmacro my-unless (c ef et)
(if c et ef))
(my-unless t (print “test”) 1)
->1
Friday, February 19, 2010
30. The my-unless macro
(defmacro my-unless (c ef et)
(if c et ef))
(my-unless t (print “test”) 1)
->1
(define *c* t)
(my-unless *c* (print “test”) 1)
Friday, February 19, 2010
31. The my-unless macro
(defmacro my-unless (c ef et)
`(if ,c ,et ,ef))
(define *c* t)
(my-unless *c* (print “test”) 1)
Friday, February 19, 2010
34. Macros taxonomy
flow modification
“with” macros -> abstracting pattens (with-file) (with-
gearman-request)
Object Oriented Lisp (CLOS) and Meta Object Protocol
Compilers, pasers, etc.
Functional lisp: monads, comonads, Tarski arrows,
currying, lazy evaluation
Friday, February 19, 2010
35. The Macro Club
The first rule of the Macro Club is Don’t Write Macros
The second rule of Macro Club is Write Macros If That
Is The Only Way to Encapsulate a Pattern
-from Programming Clojure
Friday, February 19, 2010