Escolar Documentos
Profissional Documentos
Cultura Documentos
Ilya Korsunsky
Outline
History etc. Core LISP Extending LISP Conclusions: good, bad and ugly
Outline
History etc. Core LISP
Code Processing Variables Functions Macros Special Operators The Rest
Lists
Linked lists of con cells Heterogeneous Hierarchical Some operations on lists include
..
S-expressions
Consist of lists and atoms List: white-space separated elements enclosed by parentheses
Each element is an S-expression List = ( S-exp1 S-exp2 S-expN )
S-expressions
Numbers
Rational (Integers and ratios), floating point and complex
Strings
Enclosed by double quotes Backslash (/) escapes next character
Names
Represented by symbol objects Can contain almost any character (with a few rules) Reader converts all unescaped characters into UPPER CASE (foo -> FOO but \foo = Foo) Package: a symbol table
Self-evaluating objects:
Numbers, strings, etc.
Outline
History etc. Core LISP
Code Processing Functions Variables Macros The Rest
Defining a Function
Return Values
Method ONE: last line of function is the return value. Method TWO: use return-from (special operator) to return from anywhere in the function (return-from name return-val)
Functions as Data
Accessing a function object:
(function foo) #foo
Anonymous Functions
Create a lambda function (lambda (parameters) body) Call a lambda function (funcall (lambda (x y) (+ x y)) (2 3) Used for creating closures
Outline
History etc. Core LISP
Code Processing Functions Variables Macros The Rest
Variables
Variable is a reference to any kind of object Dynamically typed (types checked at runtime) Strongly typed (object cannot be cast into another class)
Lexical Variables
Dynamic Variables
Constant Variables
Variable Assignment
Outline
History etc. Core LISP
Code Processing Functions Variables Macros The Rest
Predefined Macros
Outline
History etc. Core LISP
Code Processing Functions Variables Macros The Rest
Everything Else
Object Oriented Multithreading Data structures other than Lists Non-LISP macro: LOOP Foreign Function Interface Much much more
Outline
History etc. Core LISP Extending LISP
With Functions With Macros
Conclusions
Macro Definition
Macro Example
Macros vs Functions
Outline
History etc. Core LISP Extending LISP Conclusions: good, bad and ugly
Bottom-Up Design
Thank You!
References:
Seibel, P. Practical Common Lisp. (2005) First edition.