Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

- LISP: Introduction to lisp by DataminingTools Inc 10315 views
- A brief introduction to lisp language by David Guru 1284 views
- Introduction To Lisp by kyleburton 9680 views
- Lisp by Aniruddha Chakrab... 1447 views
- Prolog & lisp by Ismail El Gayar 11941 views
- Lisp Programming Languge by Yaser Jaradeh 2038 views

4,878 views

Published on

Presentation by Tijs van der Storm for the sept 2012 Devnology meetup at the Mirabeau offices in Amsterdam

No Downloads

Total views

4,878

On SlideShare

0

From Embeds

0

Number of Embeds

1,502

Shares

0

Downloads

89

Comments

0

Likes

4

No embeds

No notes for slide

- 1. Lisp Tijs van der StormThursday, September 6, 12
- 2. About me... • Work at Centrum Wiskunde & Informatica • Teach at Universiteit van Amsterdam in the Master Software Engineering • According to @jvandenbos “typical esoteric programming language dude” :) • Contact: storm@cwi.nl, @tvdstormThursday, September 6, 12
- 3. Interests and projects • DSLs, MDD, programming, languages • Co-designer of the Rascal metaprogramming language • Co-designer of the Ensō model-based programming environmentThursday, September 6, 12
- 4. Atze van der PloegThursday, September 6, 12
- 5. Today • About Lisp • Programming Clojure • ... meta-programmingThursday, September 6, 12
- 6. http://lambda.bugyo.tk/cdr/mwl/Thursday, September 6, 12
- 7. What is Lisp? http://lisperati.com/ • A programming language? • For LIst Processing? • The most intelligent way to misuse a computer? • Lots of Irritating Superﬂuous Parentheses? • Secret alien technology? • Oatmeal with ﬁngernail clippings mixed in? • A programmer ampliﬁer?Thursday, September 6, 12
- 8. What is Lisp? • A PL for building organisms (Perlis) • Building material (Kay) • Opposite of a Blub language (Graham) • Maxwell’s equations of software (Kay) • The greatest language ever invented (Kay)Thursday, September 6, 12
- 9. John McCarthy (September 4, 1927 – October 24, 2011)Thursday, September 6, 12
- 10. ( Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I JOHX MCCAaTItY, Massachusetts Institute of Technology, Cambridge, Mass. 1. Introduction 2. F u n c t i o n s a n d F u n c t i o n Definitions A programming system called LISP (for lASt Processor) We shMl need a number of mathematical ideas ar:d has been developed for the I B M 704 computer by the notations concerning functions in general. Most of the Artificial Intelligence group at M.I.T. The system was ideas are well known, but the notion of conditional e,~pre~- designed to facilitate experiments with a proposed system sion is believed to be new, and ihe use of conditional called the Advice Taker, whereby a machine could be expressions permits functions to be defined recursively in a instructed to handle declarative as well as imperative new and convenient way. sentences and could exhibit "common sense" in carrying a. Partial Functions. A partial function is a funct on out its instructions. The original proposal It] for the Advice that is defined only on part of its domain. Partial funetio:~s Taker was made in November 1958. The main require- necessarily arise when functions are defined by eomputa~ ment was a programming system for manipulating ex- tions because for some values of the arguments t:he Pomp:> pressions representing formalized declarative and irnpera- ration defining the value of the function may not ter- live sentences so that the Advice Taker system could make minate. However, some of our elementary functions wilt be deductions. defined as partial functions. In the course of its development the Lisp system went b. Propositional Expres.sions and Predicates. A t)ropo~i- through several stages of simplification and eventually tionM expression is an expression whose possible values came to be based on a scheme for representing the partial are T (for truth) and F (for falsity). We shall assume recursive functions of a certain class of symbolic expres- that the reader is fanfiliar with the propositionM eom~ee- sions. This representation is independent of the IBM 704 lives A ("and"), V ( " o r " ) , and ~ ( " n o t " ) , Typieai computer, or of any other electronic computer, and it now propositional expressions are: seems expedient to expound the system by starting with the class of expressions called S-expressions and the func- x<y tions called S-functions. (x < y) A (b = e) In this article, we first describe a formalism for defining functions reeursively. We believe this formalism has ad- x is prime vantages both as a programming language and as vehicle A predicate is a function whose range consists of ih{: for developing a theory of computation. Next, we describe truth values T and F. S-expressions and S-functions, give some examples, and e. Conditional Expressions. The dependence of truth then describe the universM S-function apply which plays values on the vahtes of quantities of other kinds is ex- the theoretical role of a universal Turing machine and pressed in mathematics by predicates, and the depende~ee the practical role of an interpreter. Then we describe the of truth values on other truth values by logical comxee- representation of S-expressions in the memmT of the ~ives. However, the notations for expressing symbol (alE" IBM 704 by list structures similar to those used by Newell, the dependence of quantities of other kinds on trutt~ Shaw and Simon [2], and the representation of S-functions vMues is inadequate, so that English words and phrases by program. Then we mention the main features of the are generMly used for expressing these depende~tces i:~ Lisp programming system for the IBM 704. Next comes texts that, describe other dependences symbolically. I!<~r another way of describing computations with symbolic example, the function Ix I is ustmlly defined in words. expressions, and finally we give a recursive function in- Conditional expressions are a deviee for expressing the terpretation of flow charts. dependence of quantities on propositional quantities. : We hope to describe some of the sylnbolie computations conditional expression has the form Communications of the ACM, vol 3, issue 4, April 1960 for which LISP has been used in another paper, and also to give elsewhere some applications of our reeursive function (p: -+ el, -.- , p ~ --+ e , , ) http://dx.doi.org/10.1145/367177.367199 formalism to mathematical logic and to the problem of where the ps are propositionM expressions and the es are mechanical theorem proving. expressions of any kind. It may be read, "If p~ thexx <,Thursday, September 6, 12
- 11. Last 17th of August: 50 years ago (!) http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdfThursday, September 6, 12
- 12. The famous page 13 http://xkcd.com/917/Thursday, September 6, 12
- 13. Guy L. Steele, Richard P. Gabriel, “The evolution of Lisp”, in: History of programming languages II, ACM 1996, p. 311Thursday, September 6, 12
- 14. Revised5 Report on the Algorithmic Language Scheme RICHARD KELSEY, WILLIAM CLINGER, AND JONATHAN REES (Editors) H. ABELSON R. K. DYBVIG C. T. HAYNES G. J. ROZAS N. I. ADAMS IV D. P. FRIEDMAN E. KOHLBECKER G. L. STEELE JR. D. H. BARTLEY R. HALSTEAD D. OXLEY G. J. SUSSMAN G. BROOKS C. HANSON K. M. PITMAN M. WAND Dedicated to the Memory of Robert Hieb 20 February 1998 CONTENTS Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 50 pages: SUMMARY 1 Overview of Scheme . . . . . . . . . . . . . . . . . . . . . . . 3 1.1 Semantics . . . . . . . . . . . . . . . . . . . . . . . . . 3 The report gives a deﬁning description of the program- 1.2 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 ming language Scheme. Scheme is a statically scoped and 1.3 Notation and terminology . . . . . . . . . . . . . . . . 3 pure, small, properly tail-recursive dialect of the Lisp programming 2 Lexical conventions . . . . . . . . . . . . . . . . . . . . . . . 5 language invented by Guy Lewis Steele Jr. and Gerald 2.1 Identiﬁers . . . . . . . . . . . . . . . . . . . . . . . . . 5 Jay Sussman. It was designed to have an exceptionally 2.2 Whitespace and comments . . . . . . . . . . . . . . . . 5 clear and simple semantics and few di↵erent ways to form 2.3 Other notations . . . . . . . . . . . . . . . . . . . . . . 5 “academic” 3 Basic concepts . . . . . . . . . . . . . . . . . . . . . . . . . . 6 expressions. A wide variety of programming paradigms, in- 3.1 Variables, syntactic keywords, and regions . . . . . . . 6 cluding imperative, functional, and message passing styles, 3.2 Disjointness of types . . . . . . . . . . . . . . . . . . . 6 ﬁnd convenient expression in Scheme. 3.3 External representations . . . . . . . . . . . . . . . . . 6 The introduction o↵ers a brief history of the language and 3.4 Storage model . . . . . . . . . . . . . . . . . . . . . . . 7 of the report. 3.5 Proper tail recursion . . . . . . . . . . . . . . . . . . . 7 4 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 The ﬁrst three chapters present the fundamental ideas of 4.1 Primitive expression types . . . . . . . . . . . . . . . . 8 the language and describe the notational conventions used 4.2 Derived expression types . . . . . . . . . . . . . . . . . 10 for describing the language and for writing programs in the 4.3 Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 language. 5 Program structure . . . . . . . . . . . . . . . . . . . . . . . . 16 5.1 Programs . . . . . . . . . . . . . . . . . . . . . . . . . 16 Chapters 4 and 5 describe the syntax and semantics of 5.2 Deﬁnitions . . . . . . . . . . . . . . . . . . . . . . . . . 16 expressions, programs, and deﬁnitions. 5.3 Syntax deﬁnitions . . . . . . . . . . . . . . . . . . . . 17 Chapter 6 describes Scheme’s built-in procedures, which 6 Standard procedures . . . . . . . . . . . . . . . . . . . . . . 17 include all of the language’s data manipulation and in- 6.1 Equivalence predicates . . . . . . . . . . . . . . . . . . 17 6.2 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 19 put/output primitives. 6.3 Other data types . . . . . . . . . . . . . . . . . . . . . 25 Chapter 7 provides a formal syntax for Scheme written in 6.4 Control features . . . . . . . . . . . . . . . . . . . . . . 31 extended BNF, along with a formal denotational semantics. 6.5 Eval . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 An example of the use of the language follows the formal 6.6 Input and output . . . . . . . . . . . . . . . . . . . . . 35 syntax and semantics. 7 Formal syntax and semantics . . . . . . . . . . . . . . . . . . 38 7.1 Formal syntax . . . . . . . . . . . . . . . . . . . . . . . 38 The report concludes with a list of references and an al- 7.2 Formal semantics . . . . . . . . . . . . . . . . . . . . . 40 phabetic index. 7.3 Derived expression types . . . . . . . . . . . . . . . . . 43 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Additional material . . . . . . . . . . . . . . . . . . . . . . . . 45 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Alphabetic index of deﬁnitions of concepts, keywords, and procedures . . . . . . . . . . . . . . . . 48Thursday, September 6, 12
- 15. 1029 pages: comprehensive, practical, messy, “industrial”Thursday, September 6, 12
- 16. What made Lisp different? http://paulgraham.com/diff.htmlThursday, September 6, 12
- 17. How is Lisp still different? • Homoiconic syntax • aka: there is no syntax • Macros • aka: compile-time code transformers • Code is data, data can be code • Program into the languageThursday, September 6, 12
- 18. http://xkcd.com/224/Thursday, September 6, 12
- 19. Thursday, September 6, 12
- 20. Fun resourcesThursday, September 6, 12
- 21. http://xkcd.com/297/Thursday, September 6, 12
- 22. Rich HickeyThursday, September 6, 12
- 23. • Lisp syntax, macros, code as data etc. • Functional programming, immutable data • Data structures: map, set, vector, list • Concurrency: transactional memory • Compiles to JVM, intergrates with Java • [and much more]Thursday, September 6, 12
- 24. (def basic-data-types {:booleans [true, false] :numbers [1, 2, 3.0, 4/5] :strings ["this is a string"] :symbols [a, empty?, +, user/foo] :keywords [:a-key-word]}) NB: commas, are whitespace (!)Thursday, September 6, 12
- 25. (def collection-types {:vectors [1,2,3,4] :maps {:x 3, :y 4} :sets #{a set of symbols} :lists (a list of symbols)})Thursday, September 6, 12
- 26. • Expressed using lists (Polish notation): (operator arg1 arg2 ...) • Head is applied to the arguments in tail: (+ 1 2)Thursday, September 6, 12
- 27. Special forms deﬁne (def x 3) conditional (if (> x 1) then else) (do sequencing (print "hello") (print "world!")) local vars (let [x 1] (+ x 1)) (quote (this returns a list with seven symbols)) quotation (this returns a list with seven symbols) closures (fn [x n] (+ x n))Thursday, September 6, 12
- 28. Convenience macros deﬁne a (defn power [x n] function (if (= n 0) 1 (* x (power x (- n 1))))) deﬁne a (defmacro unless [cond then else] macro `(if (not ~cond) ~then ~else))Thursday, September 6, 12
- 29. Macros! • Functions that transform code trees • aka: code that writes code template (defmacro unless [cond then else] `(if (not ~cond) ~then ~else)) quasi quote ` unquote ~Thursday, September 6, 12
- 30. Trying it in the REPL => (defmacro unless [cond then else] `(if (not ~cond) ~then ~else)) #user/unless => (unless (> 2 3) yes no) yes => (macroexpand (unless (> 2 3) yes no)) (if (clojure.core/not (> 2 3)) (quote yes) (quote no)) => (macroexpand (unless (> 2 3) (+ 1 2) (* 2 3))) (if (clojure.core/not (> 2 3)) (+ 1 2) (* 2 3))Thursday, September 6, 12
- 31. Cascading conditionals (cond [(> x y) 1] [(< x y) -1] [(= x y) 0])) rest params (defmacro cond [case & cases] (if (empty? cases) `(when ~(first case) splicing ~(second case)) unquote ~@ `(if ~(first case) ~(second case) macro (cond ~(first cases) ~@(rest cases))))) recursionThursday, September 6, 12
- 32. Testing it out => ((fn [x y] (cond [(> x y) 1] [(< x y) -1] [(= x y) 0])) 1 2) -1 => (macroexpand-all (cond [(> x y) 1] [(< x y) -1] [(= x y) 0])) (if (> x y) 1 (if (< x y) -1 (if (= x y) (do 0))))Thursday, September 6, 12
- 33. Why is this cool? • Extend the language with new abstractions • control-ﬂow • state machine • GUI builders • grammars, ... etc. • Reuse Lisp syntax / compile with macrosThursday, September 6, 12
- 34. s http://www.cwi.nl/~storm/devclj.htmlThursday, September 6, 12

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment