Common Lisp , commonly abbreviated CL , is a dialect of the Lisp programming language, published in ANSI standard document ANSI INCITS 226-1994 (R2004) , (formerly X3.226-1994 (R1999)) . From the ANSI Common Lisp standard the Common Lisp HyperSpec has been derived for use with web browsers. Common Lisp was developed to standardize the divergent variants of Lisp (though mainly the MacLisp variants) which predated it, thus it is not an implementation but rather a language specification. Several implementations of the Common Lisp standard are available, including free and open source software and proprietary products.
Common Lisp is a general-purpose, multi-paradigm programming language. It supports a combination of procedural, functional, and object-oriented programming paradigms. As a dynamic programming language, it facilitates evolutionary and incremental software development, with iterative compilation into efficient run-time programs.
Common Lisp includes CLOS, an object system that supports multimethods and method combinations. It is extensible through standard features such as Lisp macros (compile-time code rearrangement accomplished by the program itself) and reader macros (extension of syntax to give special meaning to characters reserved for users for this purpose).
Syntax
Common Lisp is a dialect of Lisp; it uses S-expressions to denote both code and data structure. Function and macro calls are written as lists, with the name of the function first, as in these examples:
( + 2 2 ) ; adds 2 and 2, yielding 4.( defvar *x* ) ; Ensures that a variable *x* exists, ; without giving it a value. The asterisks are part of ; the name. The symbol *x* is also hereby endowed with ; the property that subsequent bindings of it are dynamic, ; rather than lexical. ( setf *x* 42.1 ) ; sets the variable *x* to the floating-point value 42.1;; Define a function that squares a number: ( defun square ( x ) ( * x x ) );; Execute the function: ( square 3 ) ; Returns 9;; the 'let' construct creates a scope for local variables. Here ;; the variable 'a' is bound to 6 and the variable 'b' is bound ;; to 4. Inside the 'let' is a 'body', where the last computed value is returned. ;; Here the result of adding a and b is returned from the 'let' expression. ;; The variables a and b have lexical scope, unless the symbols have been ;; marked as special variables (for instance by a prior DEFVAR). ( let ( ( a 6 ) ( b 4 ) ) ( + a b ) ) ; returns 10Data types
Common Lisp has many data types—more than many other languages.
Scalar types
Number types include integers, ratios, floating-point numbers, and complex numbers. Common Lisp uses bignums to represent numerical values of arbitrary size and precision. The ratio type represents fractions exactly, a facility not available in many languages. Common Lisp automatically coerces numeric values among these types as appropriate.
The Common Lisp character type is not limited to ASCII characters. Most modern implementations allow Unicode characters.
The symbol type is common to Lisp languages, but largely unknown outside them. A symbol is a unique, named data object with several parts: name, value, function, property list and package. Of these, value cell and function cell are the most important. Symbols in Lisp are often used similarly to identifiers in other languages: to hold value of a variable; however there are many other uses. Normally, when a symbol is evaluated, its value is returned. Some symbols evaluate to themselves, for example all symbols in keyword package are self-evaluating. Boolean values in Common Lisp are represented by the self-evaluating symbols T and NIL. Common Lisp has namespaces for symbols, called 'packages'.
A number of functions are available for rounding scalar numeric values in various ways. The function
roundrounds the argument to the nearest integer, with halfway cases rounded to even The functionstruncate,floor, andceilinground towards zero, down, or up respectively. All these functions return the discarded fractional part as a secondary value. For example,(floor -2.5)yields -3, 0.5;(ceiling -2.5)yields -2, -0.5;(round 2.5)yields 2, 0.5; and(round 3.5)yields 4, -0.5.Data structures
Sequence types in Common Lisp include lists, vectors, bit-vectors, and strings. There are many operations which can work on any sequence type.
As in almost all other Lisp dialects, lists in Common Lisp are composed of conses , sometimes called cons cells or pairs . A cons is a data structure with two slots, called its car and cdr . A list is a linked chain of conses. Each cons's car refers to a member of the list (possibly another list). Each cons's cdr refers to the next cons -- except for the last cons, whose cdr refers to the nil value. Conses can also easily be used to implement trees and other complex data structures; though it is usually advised to use structure or class instances instead. It is also possible to create circular data structures with conses.
Common Lisp supports multidimensional arrays , and can dynamically resize arrays if required. Multidimensional arrays can be used for matrix mathematics. A vector is a one-dimensional array. Arrays can carry any type as members (even mixed types in the same array) or can be specialized to contain a specific type of members, as in a vector of integers. Many implementations can optimize array functions when the array used is type-specialized. Two type-specialized array types are standard: a string is a vector of characters, while a bit-vector is a vector of bits.
Hash tables store associations between data objects. Any object may be used as key or value. Hash tables, like arrays, are automatically resized as needed.
Packages are collections of symbols, used chiefly to separate the parts of a program into namespaces. A package may export some symbols, marking them as part of a public interface. Packages can use other packages.
Structures , similar in use to C structs and Pascal records, represent arbitrary complex data structures with any number and type of fields (called slots ). Structures allow single-inheritance.
Classes are similar to structures, but offer more dynamic features and multiple-inheritance. (See CLOS.) Classes have been added late to Common Lisp and there is some conceptual overlap with structures. Objects created of classes are called Instances . A special case are Generic Functions. Generic Functions are both functions and instances.
Functions
Common Lisp supports first-class functions. For instance, it is possible to write functions that take other functions as arguments or return functions as well. This makes it possible to describe very general operations.
The Common Lisp library relies heavily on such higher-order functions. For example, the
sortfunction takes a relational operator as an argument and key function as an optional keyword argument. This can be used not only to sort any type of data, but also to sort data structures according to a key.( sort ( list 5 2 6 3 1 4 ) #' > ) ; Sorts the list using the > function as the relational operator. ; Returns (6 5 4 3 2 1).( sort ( list ' ( 9 A ) ' ( 3 B ) ' ( 4 C ) ) #' < : key #'first ) ; Sorts the list according to the first element of each sub-list. ; Returns ((3 B) (4 C) (9 A)).The evaluation model for functions is very simple. When the evaluator encounters a form
(F A1 A2...)then it is to assume that the symbol named F is one of the following:
- A special operator (easily checked against a fixed list)
- A macro operator (must have been defined previously)
- The name of a function (default), which may either be a symbol, or a sub-form beginning with the symbol
lambda.If F is the name of a function, then the arguments A1, A2, ..., An are evaluated in left-to-right order, and the function is found and invoked with those values supplied as parameters.
Defining functions
The macro
defundefines functions. A function definition gives the name of the function, the names of any arguments, and a function body:( defun
Common Lisp HyperSpec (TM)
Welcome to the Common Lisp HyperSpec. I hope it serves your need.--Kent Pitman, X3J13 Project Editor
Common-Lisp.net
Version control, web page, rsync and other utilities for hosting Common Lisp projects.
About - Steel Bank Common Lisp
About. Steel Bank Common Lisp (SBCL) is a high performance Common Lisp compiler. It is open source / free software, with a permissive license. In addition to the compiler and runtime ...
Common Lisp info
The Common Lisp Programming Language "The programming language of choice for those who set out to solve the world's very hardest problems."
Common Lisp - Wikipedia, the free encyclopedia
Common Lisp, commonly abbreviated CL, is a dialect of the Lisp programming language, published in ANSI standard document ANSI INCITS 226-1994 (R2004), (formerly X3.226-1994 (R1999)). ...
Lisp (programming language) - Wikipedia, the free ...
Common Lisp does not support re-entrant continuations, but does support several ways of handling escape continuations. Frequently, the same algorithm can be expressed in Lisp in ...
Amazon.com: ANSI Common LISP (9780133708752): Paul ...
This item: ANSI Common LISP by Paul Graham . In Stock. Ships from and sold by Amazon.com. This item ships for FREE with Super Saver Shipping. Details
Amazon.com: Practical Common Lisp (9781590592397 ...
If you're interested in Lisp as it relates to Python or Perl, and want to learn through doing rather than watching, Practical Common Lisp is an excellent entry point.
SLIME: The Superior Lisp Interaction Mode for Emacs
SLIME: The Superior Lisp Interaction Mode for Emacs. SLIME is a Emacs mode for Common Lisp development. Inspired by existing systems such Emacs Lisp and ILISP, we are working to ...
Common Lisp
OCO: Common Lisp OCR