SlideShare a Scribd company logo
A Brief Introduction to 
Lisp Language 
Tianyu Gu 
tigu1400@student.miun.se
A Brief History 
● Originally specified in 1958, Lisp is the second-oldest high-level 
programming language in widespread use today; only Fortran is 
older (by one year). 
● Lisp stands for LISt Processing(while Fortran stands for 
FORmula TRANslator). 
● 1958 ~ 1980: Various dialects and systems, MacLisp, InterLisp, 
and Lisp Machines. 
● 1975 ~ 1980: Scheme, the first dialect choosing lexical scope, 
developed in MIT. 
● 1980 ~ 1990: Common Lisp, an industry-level language, 
published in ANSI standard. 
● 1990 ~ Now: Various implementation for Common Lisp and 
Scheme; More 3rd party libraries; A new dialect Clojure.
First Impression 
// C Code 
int factorial(int n){ 
if(n==0) 
return 1; 
else 
return n * 
factorial(n-1); 
} 
;; Common Lisp Code 
(defun factorial (n) 
(if (= n 0) 
1 
(* n 
(factorial (- n 
1)))))
First Impression: Evolution 
// C code, using tail recursion 
int factorial_helper(int result, int count){ 
if(count == 0) return result; 
else 
return factorial_helper(result*count, count-1); 
} 
int factorial(int n){ 
return factorial_helper(1, n); 
} 
;; Common Lisp code, using tail recursion 
(defun factorial (n) 
(declare (optimize (speed 3))) 
(labels ((iter (result count) 
(if (= count 0) 
result 
(iter (* result count) (1- 
count))))) 
(iter 1 n)))
First Impression: Final 'Product' 
;;;; can even use a function called ‘disassemble’ 
;;;; to check the assemble code. 
(defun factorial (n) 
(declare (optimize (speed 3))) 
(labels ((iter (result count) 
(declare (type fixnum result count)) 
(if (= count 0) 
result 
(iter (the fixnum (* result count)) 
(the fixnum (- count 1)))))) 
(iter 1 n)))
Multi-Paradigms: Functional 
Lambda(λ) 
((lambda (x y) (+ x y)) 1 2) => 3 
Map 
(map 'list #'(lambda (x) (1+ x)) (list 0 1 2 3)) => (1 2 3 4) 
Filter 
(remove-if-not #'oddp (list 1 2 3 4 5 6)) => (1 3 5) 
Fold(foldr in ML) 
(reduce #'+ (list 1 2 3 4 5)) => 15 
Curried Function, Lazy Evaluation, and more...
Multi-Paradigms: Imperative 
Common Lisp does provide imperative operators 
like: 
(setf x 10) ⇔ x := 10 
And for functional functions, Common Lisp also 
provides their ‘destructive’ version: 
map <-> map-into 
filter(remove-if-not) <-> delete-if-not 
And even more: goto, for, while...
Multi-Paradigms: OOP 
● Common Lisp has its own implementation for object 
oriented programming, which is called CLOS. 
● Unlike Java or C++, Common Lisp uses an approach 
called Generic Function instead of Message Passing. 
● Basically, all the methods belongs to generic function 
instead of a specific class. 
● For example, if there's a human class and there's a 
method called speak, then I create an instance of human 
called 'me': 
o In message passing style-> me.speak("Hello") 
o In generic function style-> speak(me, "Hello")
Multi-Paradigms: OOP
Multi-Paradigms: OOP 
A 'men' will have different behavior. 
It’s called method combination.
What Makes Lisp Special? 
1. S-Expression 
1. Macro
S-Expression 
In Common Lisp, a s-exp would be like: 
s-exp : (op s-exp1 s-exp2 ...) 
op: a function | a macro | a special form 
And interestingly, a s-exp could be ‘made’ like this: 
(cons 1 2) => (1 . 2) 
(cons 1 (cons 2 nil)) => (1 . (2 . nil)) => (1 2) 
(cons ‘+ (cons 1 (cons 2 nil))) => (+ 1 2) 
(eval (cons ‘+ (cons 1 (cons 2 nil)))) => 3
S-Expression 
A s-exp looks like a linked list but actually a tree. 
(car (list ‘+ 1 2)) => ‘+ 
(cdr (list ‘+ 1 2)) => (1 2) 
+ 
1 
2 nil 
Writing s-expressions is actually writing the 
Abstract Syntax Tree(AST).
S-Expression: Benefits 
1. There will be no lexical analysis because 
all the codes already are the AST. 
2. There will be no need to worry about the 
Operator Precedence. 
3. Very convenient to represent data 
structures like trees and graphs.
Macro: 
Why Lisp is Called 
Programmable Programming Language? 
● Unlike functions, macros will be expanded 
first before evaluated; 
● After expanding finished, the whole s-expression 
generated by macro will be 
evaluated; 
● So a macro is actually a function that 
transforms arguments to s-expressions.
Macro: A Simple Example 
In this case, it acts like a inline function.
Macro: 
A Real (but a little silly) Example 
Macros can do something that a function can never do.
Macro: A Real Example 
Macros can do something that a function can never do.
Macro: Define New Syntax
Macro: Even Let Evaluation 
Happens During ‘Compiling’ Time 
As mentioned before, a macro will be expanded before 
evaluated -- even before compiled. 
‘Counting how many numbers’ 
happens before run time.
Lisp: 
An ‘Edge’ of Programming Languages 
C++, Java ... Python, Ruby … ML, Haskell 
C Lisp
We toast the Lisp programmer who pens 
his thoughts within nests of parentheses. 
-- Alan J. Perlis 
<SICP>’s foreword 
Thanks for watching!
Ad

More Related Content

What's hot (19)

Introduction to Programming in LISP
Introduction to Programming in LISPIntroduction to Programming in LISP
Introduction to Programming in LISP
Knoldus Inc.
 
Lisp
LispLisp
Lisp
Fraboni Ec
 
(Ai lisp)
(Ai lisp)(Ai lisp)
(Ai lisp)
Ravi Rao
 
Lisp Programming Languge
Lisp Programming LangugeLisp Programming Languge
Lisp Programming Languge
Yaser Jaradeh
 
Lisp
LispLisp
Lisp
huzaifa ramzan
 
LISP: Introduction to lisp
LISP: Introduction to lispLISP: Introduction to lisp
LISP: Introduction to lisp
DataminingTools Inc
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lisp
DataminingTools Inc
 
LISP: Input And Output
LISP: Input And OutputLISP: Input And Output
LISP: Input And Output
DataminingTools Inc
 
Real World Haskell: Lecture 7
Real World Haskell: Lecture 7Real World Haskell: Lecture 7
Real World Haskell: Lecture 7
Bryan O'Sullivan
 
BayFP: Concurrent and Multicore Haskell
BayFP: Concurrent and Multicore HaskellBayFP: Concurrent and Multicore Haskell
BayFP: Concurrent and Multicore Haskell
Bryan O'Sullivan
 
Practical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan HodorogPractical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan Hodorog
3Pillar Global
 
Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...
Piotr Paradziński
 
Lisp for Python Programmers
Lisp for Python ProgrammersLisp for Python Programmers
Lisp for Python Programmers
Vsevolod Dyomkin
 
DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World Haskell
Bryan O'Sullivan
 
Real World Haskell: Lecture 1
Real World Haskell: Lecture 1Real World Haskell: Lecture 1
Real World Haskell: Lecture 1
Bryan O'Sullivan
 
Logic Programming and Prolog
Logic Programming and PrologLogic Programming and Prolog
Logic Programming and Prolog
Sadegh Dorri N.
 
Introduction to Functional Languages
Introduction to Functional LanguagesIntroduction to Functional Languages
Introduction to Functional Languages
suthi
 
Scheme Programming Language
Scheme Programming LanguageScheme Programming Language
Scheme Programming Language
Reham AlBlehid
 
Contravariant functors in scala
Contravariant functors in scalaContravariant functors in scala
Contravariant functors in scala
Piotr Paradziński
 
Introduction to Programming in LISP
Introduction to Programming in LISPIntroduction to Programming in LISP
Introduction to Programming in LISP
Knoldus Inc.
 
Lisp Programming Languge
Lisp Programming LangugeLisp Programming Languge
Lisp Programming Languge
Yaser Jaradeh
 
Real World Haskell: Lecture 7
Real World Haskell: Lecture 7Real World Haskell: Lecture 7
Real World Haskell: Lecture 7
Bryan O'Sullivan
 
BayFP: Concurrent and Multicore Haskell
BayFP: Concurrent and Multicore HaskellBayFP: Concurrent and Multicore Haskell
BayFP: Concurrent and Multicore Haskell
Bryan O'Sullivan
 
Practical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan HodorogPractical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan Hodorog
3Pillar Global
 
Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...Big picture of category theory in scala with deep dive into contravariant and...
Big picture of category theory in scala with deep dive into contravariant and...
Piotr Paradziński
 
Lisp for Python Programmers
Lisp for Python ProgrammersLisp for Python Programmers
Lisp for Python Programmers
Vsevolod Dyomkin
 
DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World Haskell
Bryan O'Sullivan
 
Real World Haskell: Lecture 1
Real World Haskell: Lecture 1Real World Haskell: Lecture 1
Real World Haskell: Lecture 1
Bryan O'Sullivan
 
Logic Programming and Prolog
Logic Programming and PrologLogic Programming and Prolog
Logic Programming and Prolog
Sadegh Dorri N.
 
Introduction to Functional Languages
Introduction to Functional LanguagesIntroduction to Functional Languages
Introduction to Functional Languages
suthi
 
Scheme Programming Language
Scheme Programming LanguageScheme Programming Language
Scheme Programming Language
Reham AlBlehid
 
Contravariant functors in scala
Contravariant functors in scalaContravariant functors in scala
Contravariant functors in scala
Piotr Paradziński
 

Viewers also liked (20)

LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)
wahab khan
 
LISP:Program structure in lisp
LISP:Program structure in lispLISP:Program structure in lisp
LISP:Program structure in lisp
DataminingTools Inc
 
Artificial intelligence Prolog Language
Artificial intelligence Prolog LanguageArtificial intelligence Prolog Language
Artificial intelligence Prolog Language
REHMAT ULLAH
 
Prolog basics
Prolog basicsProlog basics
Prolog basics
shivani saluja
 
PROLOG: Introduction To Prolog
PROLOG: Introduction To PrologPROLOG: Introduction To Prolog
PROLOG: Introduction To Prolog
DataminingTools Inc
 
Pathfinding algorithms
Pathfinding algorithmsPathfinding algorithms
Pathfinding algorithms
Dimos Raptis
 
Artificial Intelligence Algorithms
Artificial Intelligence AlgorithmsArtificial Intelligence Algorithms
Artificial Intelligence Algorithms
IOSR Journals
 
02-Unidad 1 Generalidades de la Inteligencia Artificial
02-Unidad 1 Generalidades de la Inteligencia Artificial02-Unidad 1 Generalidades de la Inteligencia Artificial
02-Unidad 1 Generalidades de la Inteligencia Artificial
Facultad de Ciencias y Sistemas
 
Redesigning Common Lisp
Redesigning Common LispRedesigning Common Lisp
Redesigning Common Lisp
fukamachi
 
Digital image processing
Digital image processingDigital image processing
Digital image processing
Deevena Dayaal
 
Lisp
LispLisp
Lisp
Carlos Solano
 
Image processing1 introduction
Image processing1 introductionImage processing1 introduction
Image processing1 introduction
Preeti Gupta
 
Digital Image Processing: An Introduction
Digital Image Processing: An IntroductionDigital Image Processing: An Introduction
Digital Image Processing: An Introduction
Mostafa G. M. Mostafa
 
Lecture 11 Informed Search
Lecture 11 Informed SearchLecture 11 Informed Search
Lecture 11 Informed Search
Hema Kashyap
 
The type writer
The type writerThe type writer
The type writer
bsiegmund
 
Introduccion a los lenguajes de programacion para Inteligencia Artificial
Introduccion a los lenguajes de programacion para Inteligencia ArtificialIntroduccion a los lenguajes de programacion para Inteligencia Artificial
Introduccion a los lenguajes de programacion para Inteligencia Artificial
Brian Pando
 
Proyecto Areas Inteligencia Artificial Javier Garcia
Proyecto Areas Inteligencia Artificial Javier GarciaProyecto Areas Inteligencia Artificial Javier Garcia
Proyecto Areas Inteligencia Artificial Javier Garcia
Javier García García
 
Lecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithmLecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithm
Hema Kashyap
 
Tape recorder - by Ema
Tape recorder - by EmaTape recorder - by Ema
Tape recorder - by Ema
NarandaIva
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image Processing
Reshma KC
 
LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)
wahab khan
 
Artificial intelligence Prolog Language
Artificial intelligence Prolog LanguageArtificial intelligence Prolog Language
Artificial intelligence Prolog Language
REHMAT ULLAH
 
Pathfinding algorithms
Pathfinding algorithmsPathfinding algorithms
Pathfinding algorithms
Dimos Raptis
 
Artificial Intelligence Algorithms
Artificial Intelligence AlgorithmsArtificial Intelligence Algorithms
Artificial Intelligence Algorithms
IOSR Journals
 
Redesigning Common Lisp
Redesigning Common LispRedesigning Common Lisp
Redesigning Common Lisp
fukamachi
 
Digital image processing
Digital image processingDigital image processing
Digital image processing
Deevena Dayaal
 
Image processing1 introduction
Image processing1 introductionImage processing1 introduction
Image processing1 introduction
Preeti Gupta
 
Digital Image Processing: An Introduction
Digital Image Processing: An IntroductionDigital Image Processing: An Introduction
Digital Image Processing: An Introduction
Mostafa G. M. Mostafa
 
Lecture 11 Informed Search
Lecture 11 Informed SearchLecture 11 Informed Search
Lecture 11 Informed Search
Hema Kashyap
 
The type writer
The type writerThe type writer
The type writer
bsiegmund
 
Introduccion a los lenguajes de programacion para Inteligencia Artificial
Introduccion a los lenguajes de programacion para Inteligencia ArtificialIntroduccion a los lenguajes de programacion para Inteligencia Artificial
Introduccion a los lenguajes de programacion para Inteligencia Artificial
Brian Pando
 
Proyecto Areas Inteligencia Artificial Javier Garcia
Proyecto Areas Inteligencia Artificial Javier GarciaProyecto Areas Inteligencia Artificial Javier Garcia
Proyecto Areas Inteligencia Artificial Javier Garcia
Javier García García
 
Lecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithmLecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithm
Hema Kashyap
 
Tape recorder - by Ema
Tape recorder - by EmaTape recorder - by Ema
Tape recorder - by Ema
NarandaIva
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image Processing
Reshma KC
 
Ad

Similar to A brief introduction to lisp language (20)

LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола Мозговий
Sigma Software
 
Clojure intro
Clojure introClojure intro
Clojure intro
Basav Nagur
 
Introduction to Functional Programming with Clojure
Introduction to Functional Programming with ClojureIntroduction to Functional Programming with Clojure
Introduction to Functional Programming with Clojure
Wilton Silva
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
LISP Content
 
Report about the LISP Programming Language
Report about the LISP Programming LanguageReport about the LISP Programming Language
Report about the LISP Programming Language
maldosmelandrew
 
Functional Programming - Past, Present and Future
Functional Programming - Past, Present and FutureFunctional Programming - Past, Present and Future
Functional Programming - Past, Present and Future
Pushkar Kulkarni
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present Future
IndicThreads
 
AI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxAI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptx
prakashvs7
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
callroom
 
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmers
amiable_indian
 
ppt2
ppt2ppt2
ppt2
callroom
 
name name2 n
name name2 nname name2 n
name name2 n
callroom
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
callroom
 
ppt30
ppt30ppt30
ppt30
callroom
 
name name2 n
name name2 nname name2 n
name name2 n
callroom
 
ppt21
ppt21ppt21
ppt21
callroom
 
name name2 n
name name2 nname name2 n
name name2 n
callroom
 
ppt17
ppt17ppt17
ppt17
callroom
 
ppt7
ppt7ppt7
ppt7
callroom
 
ppt9
ppt9ppt9
ppt9
callroom
 
LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола Мозговий
Sigma Software
 
Introduction to Functional Programming with Clojure
Introduction to Functional Programming with ClojureIntroduction to Functional Programming with Clojure
Introduction to Functional Programming with Clojure
Wilton Silva
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
LISP Content
 
Report about the LISP Programming Language
Report about the LISP Programming LanguageReport about the LISP Programming Language
Report about the LISP Programming Language
maldosmelandrew
 
Functional Programming - Past, Present and Future
Functional Programming - Past, Present and FutureFunctional Programming - Past, Present and Future
Functional Programming - Past, Present and Future
Pushkar Kulkarni
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present Future
IndicThreads
 
AI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxAI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptx
prakashvs7
 
name name2 n2.ppt
name name2 n2.pptname name2 n2.ppt
name name2 n2.ppt
callroom
 
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmers
amiable_indian
 
name name2 n
name name2 nname name2 n
name name2 n
callroom
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
callroom
 
name name2 n
name name2 nname name2 n
name name2 n
callroom
 
name name2 n
name name2 nname name2 n
name name2 n
callroom
 
Ad

A brief introduction to lisp language

  • 1. A Brief Introduction to Lisp Language Tianyu Gu tigu1400@student.miun.se
  • 2. A Brief History ● Originally specified in 1958, Lisp is the second-oldest high-level programming language in widespread use today; only Fortran is older (by one year). ● Lisp stands for LISt Processing(while Fortran stands for FORmula TRANslator). ● 1958 ~ 1980: Various dialects and systems, MacLisp, InterLisp, and Lisp Machines. ● 1975 ~ 1980: Scheme, the first dialect choosing lexical scope, developed in MIT. ● 1980 ~ 1990: Common Lisp, an industry-level language, published in ANSI standard. ● 1990 ~ Now: Various implementation for Common Lisp and Scheme; More 3rd party libraries; A new dialect Clojure.
  • 3. First Impression // C Code int factorial(int n){ if(n==0) return 1; else return n * factorial(n-1); } ;; Common Lisp Code (defun factorial (n) (if (= n 0) 1 (* n (factorial (- n 1)))))
  • 4. First Impression: Evolution // C code, using tail recursion int factorial_helper(int result, int count){ if(count == 0) return result; else return factorial_helper(result*count, count-1); } int factorial(int n){ return factorial_helper(1, n); } ;; Common Lisp code, using tail recursion (defun factorial (n) (declare (optimize (speed 3))) (labels ((iter (result count) (if (= count 0) result (iter (* result count) (1- count))))) (iter 1 n)))
  • 5. First Impression: Final 'Product' ;;;; can even use a function called ‘disassemble’ ;;;; to check the assemble code. (defun factorial (n) (declare (optimize (speed 3))) (labels ((iter (result count) (declare (type fixnum result count)) (if (= count 0) result (iter (the fixnum (* result count)) (the fixnum (- count 1)))))) (iter 1 n)))
  • 6. Multi-Paradigms: Functional Lambda(λ) ((lambda (x y) (+ x y)) 1 2) => 3 Map (map 'list #'(lambda (x) (1+ x)) (list 0 1 2 3)) => (1 2 3 4) Filter (remove-if-not #'oddp (list 1 2 3 4 5 6)) => (1 3 5) Fold(foldr in ML) (reduce #'+ (list 1 2 3 4 5)) => 15 Curried Function, Lazy Evaluation, and more...
  • 7. Multi-Paradigms: Imperative Common Lisp does provide imperative operators like: (setf x 10) ⇔ x := 10 And for functional functions, Common Lisp also provides their ‘destructive’ version: map <-> map-into filter(remove-if-not) <-> delete-if-not And even more: goto, for, while...
  • 8. Multi-Paradigms: OOP ● Common Lisp has its own implementation for object oriented programming, which is called CLOS. ● Unlike Java or C++, Common Lisp uses an approach called Generic Function instead of Message Passing. ● Basically, all the methods belongs to generic function instead of a specific class. ● For example, if there's a human class and there's a method called speak, then I create an instance of human called 'me': o In message passing style-> me.speak("Hello") o In generic function style-> speak(me, "Hello")
  • 10. Multi-Paradigms: OOP A 'men' will have different behavior. It’s called method combination.
  • 11. What Makes Lisp Special? 1. S-Expression 1. Macro
  • 12. S-Expression In Common Lisp, a s-exp would be like: s-exp : (op s-exp1 s-exp2 ...) op: a function | a macro | a special form And interestingly, a s-exp could be ‘made’ like this: (cons 1 2) => (1 . 2) (cons 1 (cons 2 nil)) => (1 . (2 . nil)) => (1 2) (cons ‘+ (cons 1 (cons 2 nil))) => (+ 1 2) (eval (cons ‘+ (cons 1 (cons 2 nil)))) => 3
  • 13. S-Expression A s-exp looks like a linked list but actually a tree. (car (list ‘+ 1 2)) => ‘+ (cdr (list ‘+ 1 2)) => (1 2) + 1 2 nil Writing s-expressions is actually writing the Abstract Syntax Tree(AST).
  • 14. S-Expression: Benefits 1. There will be no lexical analysis because all the codes already are the AST. 2. There will be no need to worry about the Operator Precedence. 3. Very convenient to represent data structures like trees and graphs.
  • 15. Macro: Why Lisp is Called Programmable Programming Language? ● Unlike functions, macros will be expanded first before evaluated; ● After expanding finished, the whole s-expression generated by macro will be evaluated; ● So a macro is actually a function that transforms arguments to s-expressions.
  • 16. Macro: A Simple Example In this case, it acts like a inline function.
  • 17. Macro: A Real (but a little silly) Example Macros can do something that a function can never do.
  • 18. Macro: A Real Example Macros can do something that a function can never do.
  • 20. Macro: Even Let Evaluation Happens During ‘Compiling’ Time As mentioned before, a macro will be expanded before evaluated -- even before compiled. ‘Counting how many numbers’ happens before run time.
  • 21. Lisp: An ‘Edge’ of Programming Languages C++, Java ... Python, Ruby … ML, Haskell C Lisp
  • 22. We toast the Lisp programmer who pens his thoughts within nests of parentheses. -- Alan J. Perlis <SICP>’s foreword Thanks for watching!

Editor's Notes

  • #4: Dynamic but Strong Type
  翻译: