Lisp (programming language): Difference between revisions

Content deleted Content added
note on the drawing style
Tag: Reverted
m An article about Lisp must have balanced parentheses!
 
(6 intermediate revisions by 4 users not shown)
Line 3:
{{Infobox programming language
| name = Lisp
| logo = Lisp logo.svg
| logo size = 150px
| paradigm = [[Multi-paradigm programming language|Multi-paradigm]]: [[Functional programming|functional]], [[Procedural programming|procedural]], [[Reflective programming|reflective]], [[Metaprogramming|meta]]
| released = {{Start date and age|1960}}
Line 99 ⟶ 97:
{{Multiple image |direction=vertical |image1=John McCarthy Stanford.jpg |image2=Steve Russell.jpg |footer=[[John McCarthy (computer scientist)|John McCarthy]] (top) and [[Steve Russell (computer scientist)|Steve Russell]]}}
 
[[John McCarthy (computer scientist)|John McCarthy]] began developing Lisp in 1958 while he was at the [[Massachusetts Institute of Technology]] (MIT). He was motivated by a desire to create an AI programming language that would work on the [[IBM 704]], as he believed that "IBM looked like a good bet to pursue Artificial Intelligence research vigorously."<ref name="wexelblat-history-programming-languages">{{cite book |title=History of programming languages |last1=McCarthy |first1=John |last2=Wexelblat |first2=Richard L. |year=1978 |isbn=0127450408 |publisher=Association for Computing Machinery |pages=173–183}}</ref> He was inspired by [[Information Processing Language]], which was also based on list processing, but did not use it because it was designed for different hardware and he found an algebraic language more appealing.<ref name="wexelblat-history-programming-languages" /> Due to these factors, he consulted on the design of the [[Fortran]] List Processing Language, which was implemented as a Fortran library. However, he was dissatisfied with it because it did not support [[Recursion (computer science)|recursion]] or a modern [[Conditional (computer programming)#If–then(–else)|if-then-else]] statement (which was a new concept when lispLisp was first introduced) {{NoteTag|At the time, Fortran had an if-then-else construct that accepted line numbers as jump targets, in the manner of a [[Goto]] statement, rather than accepting arbitrary expression in "then" and "else" blocks}}.<ref name="wexelblat-history-programming-languages" />
 
McCarthy's original notation used bracketed "[[M-expression]]s" that would be translated into [[S-expression]]s. As an example, the M-expression {{Lisp2|car[cons[A,B]]}} is equivalent to the S-expression {{Lisp2|(car (cons A B))}}. Once Lisp was implemented, programmers rapidly chose to use S-expressions, and M-expressions were abandoned.<ref name="wexelblat-history-programming-languages"/> M-expressions surfaced again with short-lived attempts of [[MLisp]]<ref name="Smith">{{cite book |last=Smith |first=David Canfield |title=MLISP Users Manual |url=http://www.softwarepreservation.org/projects/LISP/stanford/Smith-MLISP-AIM-84.pdf |access-date=2006-10-13}}</ref> by Horace Enea and [[CGOL]] by [[Vaughan Pratt]].
Line 118 ⟶ 116:
[[Garbage collection (computer science)|Garbage collection]] routines were developed by MIT graduate student [[Daniel Edwards (programmer)|Daniel Edwards]], prior to 1962.<ref>{{cite book |title=LISP 1.5 Programmer's Manual |url=http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf |page=Preface |orig-date=1962 |year=1985 |version=15th printing |last1=McCarthy |first1=John |last2=Abrahams |first2=Paul W. |last3=Edwards |first3=Daniel J. |last4=Hart |first4=Timothy P. |last5=Levin |first5=Michael I. |edition=2nd}}</ref>
 
During the 1980s and 1990s, a great effort was made to unify the work on new Lisp dialects (mostly successors to [[Maclisp]] such as [[ZetaLisp]] and NIL (New Implementation of Lisp)) into a single language. The new language, [[Common Lisp]], was somewhat compatible with the dialects it replaced (the book ''[[Common Lisp the Language]]'' notes the compatibility of various constructs). In 1994, [[ANSI]] published the Common Lisp standard, "ANSI X3.226-1994 Information Technology Programming Language Common Lisp".
 
=== Timeline ===
Line 306 ⟶ 304:
Of the many data structures that can be built out of cons cells, one of the most basic is called a ''proper list''. A proper list is either the special {{Lisp2|nil}} (empty list) symbol, or a cons in which the {{Lisp2|car}} points to a datum (which may be another cons structure, such as a list), and the {{Lisp2|cdr}} points to another proper list.
 
If a given cons is taken to be the head of a linked list (which it normally is), then its car points to the first element of the list, and its cdr points to the rest of the list. For this reason, the {{Lisp2|car}} and {{Lisp2|cdr}} functions are also called {{Lisp2|first}} and {{Lisp2|rest}} when referring to conses which are part of a linked list (rather than, say, a tree). This explains the iconographic particularity of the cons-cell being depicted with the cdr reference continuing on the same level.
 
Thus, a Lisp list is not an atomic object, as an instance of a container class in C++ or Java would be. A list is nothing more than an aggregate of linked conses. A variable that refers to a given list is simply a pointer to the first cons in the list. Traversal of a list can be done by ''cdring down'' the list; that is, taking successive cdrs to visit each cons of the list; or by using any of several [[higher-order function]]s to map a function over a list.