Lisp (what ITA might have that we don't)
Table of Contents
- 1. Quick Overview
- 1.1. History and stuff
- 1.1.1. One of the oldest programming languages still in use
- 1.1.2. Actually a family of languages
- 1.1.3. Academic wing (Scheme), industrial wing (Common Lisp, maybe Clojure)
- 1.1.4. Starting in days of limited hardware, it's quite efficient
- 1.1.5. Accidentally or not, raised by the Artificial Intelligence pioneers and for long time being the standard there
- 1.1.6. Lots of groundbreaking ideas for its time, most of them have slowly crept to mainstream and are now taken for granted (garbage collection, dynamic typing, tree data structures, interactive development)
- 1.1.7. Easy to implement, has standards, lots of realisations
- 1.1.8. Based on Alonzo Church's lambda calculus
- 1.2. Common Lisp nowadays
- 1.2.1. Never quite in the mainstream, but with somewhat growing interest in recent years
- 1.2.2. Aging standard but the language doesn't feel handicapped
- 1.2.3. HyperSpec, excellent documentation
- 1.2.4. Lots of implementations, 2 of them commercial
- 1.2.5. The most popular open source implementation SBCL (Steel Bank Common Lisp) is actually the fastest and written in…Common Lisp
- 1.2.6. Small community but with increasingly better library support
- 1.2.7. Lots of great books
- 1.2.8. Known usage includes 3D graphics suits, game engines, semantic web reasoning systems, knowledge and rule based systems, theorem provers, compilers, algebra systems, telecom systems, fare search engine…
- 1.3. Technical features
- 1.3.1. Multi-paradigm: supports procedural, functional and object-oriented styles out of the box
- 1.3.2. Minimal, consistent syntax based on S-expressions
- 1.3.3. Code is data
- 1.3.4. Programmer has essentially everything that the language creators have had, great extensibility
- 1.3.5. Dynamic typing with optional type annotation
- 1.3.6. Read Eval Print Loop
- 1.3.7. Supports incremental development
- 1.3.8. Efficiently compiled
- 1.3.9. Macros
- 1.3.10. Condition system
- 1.3.11. CLOS
- 1.1. History and stuff
- 2. The Language
- 2.1. S-expressions and evaluation
- 2.1.1. S-expressions (lists) are actually the abstract syntax tree that directly feeds the lisp compiler
- 2.1.2. Each S-expression returns a value
- 2.1.3. Evaluating non empty list normally asks the environment for the function/macro represented by the first symbol.
- 2.1.4. When function, rest of the list is treated like arguments that are also evaluated and passed to the function.
- 2.1.5. When macro, rest of the list is treated like arguments that are passed as they are to the macro.
- 2.1.6. Lists are treated as function/macro invocations unless quoted
- 2.2. Variables
- 2.3. Variables (continued)
- 2.4. Functions
- 2.5. Macros
- 2.6. Condition System
- 2.7. Condition System (continued)
- 2.8. Condition System (continued)
- 2.9. Common Lisp Object System
- 2.1. S-expressions and evaluation
- 3. A bit of code
- 4. Resources
- 4.1. Books
- 4.1.1. Practical Common Lisp
- 4.1.2. HyperSpec
- 4.1.3. Common Lisp the Language, 2nd Edition
- 4.1.4. On Lisp: Advanced Techniques for Common Lisp
- 4.1.5. Common Lisp: A Gentle Introduction to Symbolic Computation
- 4.1.6. Paradigms of Artificial Intelligence Programming
- 4.1.7. Structure and Interpretation of Computer Programs
- 4.2. Links
- 4.1. Books
- 5. Fun
1 Quick Overview
1.1 History and stuff
1.1.1 One of the oldest programming languages still in use
1.1.2 Actually a family of languages
1.1.3 Academic wing (Scheme), industrial wing (Common Lisp, maybe Clojure)
1.1.4 Starting in days of limited hardware, it's quite efficient
1.1.5 Accidentally or not, raised by the Artificial Intelligence pioneers and for long time being the standard there
1.1.6 Lots of groundbreaking ideas for its time, most of them have slowly crept to mainstream and are now taken for granted (garbage collection, dynamic typing, tree data structures, interactive development)
1.1.7 Easy to implement, has standards, lots of realisations
1.1.8 Based on Alonzo Church's lambda calculus
1.2 Common Lisp nowadays
1.2.1 Never quite in the mainstream, but with somewhat growing interest in recent years
1.2.2 Aging standard but the language doesn't feel handicapped
1.2.3 HyperSpec, excellent documentation
1.2.4 Lots of implementations, 2 of them commercial
1.2.5 The most popular open source implementation SBCL (Steel Bank Common Lisp) is actually the fastest and written in…Common Lisp
1.2.6 Small community but with increasingly better library support
1.2.7 Lots of great books
1.2.8 Known usage includes 3D graphics suits, game engines, semantic web reasoning systems, knowledge and rule based systems, theorem provers, compilers, algebra systems, telecom systems, fare search engine…
1.3 Technical features
1.3.1 Multi-paradigm: supports procedural, functional and object-oriented styles out of the box
1.3.2 Minimal, consistent syntax based on S-expressions
1.3.3 Code is data
1.3.4 Programmer has essentially everything that the language creators have had, great extensibility
1.3.5 Dynamic typing with optional type annotation
1.3.6 Read Eval Print Loop
1.3.7 Supports incremental development
1.3.8 Efficiently compiled
1.3.9 Macros
1.3.10 Condition system
1.3.11 CLOS
2 The Language
2.1 S-expressions and evaluation
2.1.1 S-expressions (lists) are actually the abstract syntax tree that directly feeds the lisp compiler
2.1.2 Each S-expression returns a value
2.1.3 Evaluating non empty list normally asks the environment for the function/macro represented by the first symbol.
2.1.4 When function, rest of the list is treated like arguments that are also evaluated and passed to the function.
(some-function arguments that are first evaluated)
2.1.5 When macro, rest of the list is treated like arguments that are passed as they are to the macro.
(some-macro arguments passed as they are)
2.1.6 Lists are treated as function/macro invocations unless quoted
'(some list with unevaluated elements)
2.2 Variables
2.2.1 Lexical scope by default, with a twist
2.2.2 Closures B_example
(let ((counter 0)) (defun inc-counter () (incf counter)) (defun dec-counter () (decf counter)))
2.3 Variables (continued)
2.3.1 Dynamic aka special variables B_example
(defparameter *debug* nil) (defun bla-bla () (no-debugging) (let ((*debug* t)) (do-some-stuff-with-debugging)) (no-debugging))
2.4 Functions
2.4.1 First class citizens
2.4.2 Anonymous functions
2.4.3 Functions as data
2.4.4 Multiple return values
2.5 Macros
2.5.1 Program life-cycle
2.5.2 Run-time vs. compilation
2.5.3 Macro expansion time
2.5.4 Programming the compiler
2.5.5 Almost like functions on the outside
2.5.6 Programming over the source code with all the power of the language
2.6 Condition System
2.6.1 Beyond exception handling
2.6.2 Conditions and restarts
2.6.3 Condition handlers
2.6.4 handler-case similar to catch B_example
(handler-case (progn (do-stuff) (do-more-stuff)) (some-exception (se) (recover se)))
\hfill \(\qed\)
2.7 Condition System (continued)
2.7.1 restart-case B_example
(defun parse-log-file (file) (with-open-file (in file :direction :input) (loop for text = (read-line in nil nil) while text for entry = (restart-case (parse-log-entry text) (skip-log-entry () nil)) when entry collect it)))
2.8 Condition System (continued)
2.8.1 handler-bind B_example
(defun log-analyzer () (handler-bind ((malformed-log-entry-error #'(lambda (c) (invoke-restart'skip-log-entry)))) (dolist (log (find-all-logs)) (analyze-log log))))
2.8.2 Signals, why just errors
2.8.3 Restarts at lower levels, handlers at higher
2.9 Common Lisp Object System
2.9.1 Message passing
2.9.2 Decoupling classes from methods
2.9.3 Generic functions
2.9.4 Method combinations
2.9.5 Multimethods
3 A bit of code
3.1 Switch to Emacs please
…
4 Resources
4.1 Books
4.1.1 Practical Common Lisp
4.1.2 HyperSpec
4.1.6 Paradigms of Artificial Intelligence Programming
4.2 Links
4.2.1 CLiki
4.2.2 CL resources
4.2.7 Steel Bank Common Lisp
4.2.8 Some SBCL benchmarks
4.2.9 Franz Inc.
4.2.10 LispWorks
5 Fun
Land of Lisp- The Music Video!
Figure 1: Secret alien technology
Figure 2: Lispers
Figure 3: Fanboys