1 / 15

Lisp Basics and Idioms

Lisp Is Old. 1958: John McCarthy writes an algebraic list processing language for AI workMcCarthy's grad student wrote an interpreter for it Strongly tied to AI research during the 70s and 80sFell from prominence during the AI Winter. Lisp Is New. Paul Graham's essays ? ?Beating the Averages", ?L

beth
Télécharger la présentation

Lisp Basics and Idioms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. Lisp Basics and Idioms

    2. Lisp Is Old 1958: John McCarthy writes an algebraic list processing language for AI work McCarthys grad student wrote an interpreter for it Strongly tied to AI research during the 70s and 80s Fell from prominence during the AI Winter

    3. Lisp Is New Paul Grahams essays Beating the Averages, Lisp in Web-Based Applications Eric Raymond "LISP is worth learning for the profound enlightenment experience you will have when you finally get it. That experience will make you a better programmer for the rest of your days, even if you never actually use LISP itself a lot. Recent development of open source versions

    4. Lisp is a Family of Languages Common Lisp: ANSI Standard written in the 80s caused languages to coalesce, then implementations to flourish Scheme: A conceptually cleaner variant with a smaller specification Proprietary: LispWorks, Allegro Open Source: SBCL, CLisp Others: compile to C, run on JVM, etc

    5. Lisp is Functional, But Not Strictly Functional is the most natural to write Can make sequential blocks, either explicitly or in constructs Can make and change values if needed Can build and incorporate new paradigms as necessary, i.e. CLOS Lisp is strongly typed, dynamic typed

    6. Lisp Has Lots of Parentheses "Lisp has all the visual appeal of oatmeal with fingernail clippings mixed in." -Larry Wall Used to group expressions Makes syntax simple and consistent Most forms are (function args*)

    7. But the Parentheses Arent a Big Deal "Parentheses? What parentheses? I haven't noticed any parentheses since my first month of Lisp programming. I like to ask people who complain about parentheses in Lisp if they are bothered by all the spaces between words in a newspaper" - Ken Tilton Editors indent automatically Emacs commands to balance and close parens Paredit (Emacs library) lets you manipulate sexps directly

    8. Lisp Uses Symbols Like variables but better Like pointers but less dangerous Assign a name to a value Values can be lots of things numbers, strings, functions, lists, other data structures

    9. Lisp Has First Class Functions Easy to define (defun hello-world () (format t hello, world)) Can be passed as parameters Can be returned as values from other functions Anonymous functions too!

    10. Lisp Has Flexible Parameters Parameters can be optional, with defaults (defun foo (a &optional b) (list a b)) (defun foo2 (a &optional (b 10)) (list a b)) Parameter lists can be variable length (defun + (&rest numbers) ) Keyword parameters (defun foo3 (&key a b) )

    11. Lisp Uses Pairs Lists are chains of pairs Can make other trees, etc as well

More Related