PART A Emac Lisp Emac Lisp is a programming language Emacs Lisp is a dialect.
Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages....
Transcript of Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages....
![Page 1: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/1.jpg)
A Tale of Two LispsClick to add subtle
![Page 2: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/2.jpg)
LISP is a family of languages.
Though each member of this family has its own quirks, they all share the common attributes of LISP:
● Interactive (REPL)● Polish Notation (S-expressions)● LISP Programs are Lists (homoiconic)
20 minute crash course in LISP
![Page 3: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/3.jpg)
Core Concepts of Lisp
Real Metaprogrammingperl "macros"C macros
Code as datarun-time programming
S-expressionsMacros
backquote comma syntax
![Page 4: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/4.jpg)
What you expect out of Lisp
Garbage collectionMulti-paradigm programming
functionalimperativeobject-oriented
Dynamic typingHomoiconicityLists
OMG lists
![Page 5: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/5.jpg)
Examples
● Syntax● Functions● Macros
![Page 6: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/6.jpg)
Syntax
LISP syntax is very regular.
A LISP program is just a sequence of lists.
Because of this, LISP code can be manipulated by LISP (which is the List processing language after all)
![Page 7: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/7.jpg)
Functions
Value slot vs Function slotWhat sorts of things can be functions?
Things that have been defun'dLambda expressionsSymbols
Using funcallWays you should never bind a function
![Page 8: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/8.jpg)
Macros
Code is data.QuotingEval exampleHow macros work
a simple macro examplea more complex macro example
It is possible to write code at runtime
![Page 9: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/9.jpg)
Two Theories of Computation
● Turing Machine
State Machine +Tape
● Lambda Calculus
Combinations of Functions
![Page 10: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/10.jpg)
Equal but Different
Turing Machines → procedural, imperative style.
Assembly, ALGOL, FORTRAN, C, etc
Lambda Calculus → compose functions.
Haskell, LISP
![Page 11: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/11.jpg)
Timeline
1956: lisp is conceived1958: first implementation (IBM 704)1962-1970ish: Maclisp
On the PDP-10 and other machines1981: Zetalisp (Lisp Machine Lisp)1984: Common Lisp the Language1985: *LISP / Emacs LISP1994: ANSI Common Lisp2007: Clojure 1.0
![Page 12: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/12.jpg)
Early LISP (1960)
Invented by John McCarthy here at MIT.First Implemented by Steve Russel on an IBM 704 computer.
![Page 13: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/13.jpg)
LISP 1
M-Expressions --> S-expressions
![Page 14: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/14.jpg)
LISP 1
The first interpreter for LISP on the IBM 704 had:● Garbage Collection (“reclamation cycle”)● Recursive Functions/Stack (“public push-
down list”)● No M-Expressions (they didn't have time to
implement them!)● No Macros● REPL !! (Flexowriter)
![Page 15: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/15.jpg)
Maclisp
setfbit vectorsarraysstringsfloats and bignumsno lexical scopingloop macrofewer equality forms than CLflexible read base
![Page 16: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/16.jpg)
Zetalisp
everything in maclispcomplex numbersrationalslexical scopingdynamic closuresobject system (flavors)base 8 (default)
![Page 17: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/17.jpg)
Zetalisp Demo
Dynamic closuresLists as functions
![Page 18: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/18.jpg)
Common Lisp
Significant influence from ZetalispCLOS (common lisp object system)
- multiple inheritanceLanguage is static: old libraries still work
![Page 19: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/19.jpg)
*LISP (Connection Machine)
Common Lisp, with macros which enabled use of parallel variables
![Page 20: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/20.jpg)
EMACS LISP
Mostly used for scripting new functions for editing files with EMACS.
Dynamically Scoped --- interferes with closures.
![Page 21: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/21.jpg)
Clojure
Released by Rich Hickey in 2007.
Integrates with Java and the JVM
Advanced support for parallel, thread-safe code.
Immutable data structures.
![Page 22: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/22.jpg)
Lisp Trivia
LISP is second oldest language in modern use.
Used in AutoCAD, Emacs, Reddit, GIMP, Crash Bandicoot, Toy Story.
Gollum from Lord of the Rings was animated on a Symbolics Lisp Machine.
![Page 23: Click to add subtle - MITweb.mit.edu/rlm/Public/lisp/lisp.pdf · LISP is a family of languages. Though each member of this family has its own quirks, they all share the common attributes](https://reader030.fdocuments.us/reader030/viewer/2022040420/5e05976d1e361e2d7f3265fa/html5/thumbnails/23.jpg)
Trivial Trivia
The computer from Jurassic Park was a Connection Machine Model CM-5.