Lisp the language

来源:互联网 发布:数据可视化 陈为 下载 编辑:程序博客网 时间:2024/05/30 04:39
  1. Born of LISP

At first,computers were invited to do numerical computing. But in order to perform numerical tasks efficiently, it had to be given important non-numerical capabilities(Herbert 1980). When we give the computer the instruction “add 3 and 3”, we expect it to answer “6”.This means that it has to understand the meaning of the instruction word “add”, however that word may be symbolized and in whatever programming language.

A computer is an example of a physical symbol system. There is a physical symbol system hypothesis: a physical symbol system not only can exhibit intelligence but also can do so by adopting the same methods that human beings adopt in solving problems in the same problem domains—that is, that one can program a computer to simulate human cognitive processes. The term “intelligence” in the hypothesis also needs definition. A system is intelligent if, when given problems that we and other human beings regard as difficult, it is able to discover solutions for those problems.

Thus,non-numerical computation has two main branches. The first, usually called “artificial intelligence”, is aimed at programming computers to behave intelligently. The second, usually called“cognitive simulation”, is aimed at achieving artificial intelligence in a humanoid way, by simulating human methods.

It was recognized very early that if you are to get a computer to do tasks that require it to explore in unpredictable directions, you must develop software techniques for organizing memories to accommodate the unpredictable or at least the unpredicted. Because the shape of that search tree cannot be anticipated because certain branches may grow very large, the usual techniques for organizing computer memory by reassigning specific blocks to specific foreseen users will notwork.

So a technique had to be developed in the middle 1950s, at the same time that Fortran-like languages were being developed, to handle irregularly shaped search trees. The particular solution that was found for this problem for artificial intelligence purposes, but which also found other important applications in computing, is called “list processing”. It is a software technique that can be used with standard computer hardware.

The first list-processing languages were a series called IPL(Information Processing Language); the most widely used today is a language called LISP.(Herbert 1980) Though it can be used with standard computer hardware, it not run as fast as Fortran-like languages. And there are people are designing computers that will have list-processing capabilities built into hardware, with a consequent major gain in speed of execution.

  1. Introduction to LISP

The name LISP is an acronym for LISt Processing. The origin version of the programming language LISP was developed at the MIT in the late 1950s under the direction of John McCarthy(died on 10/24/2011).It was designed specifically for list processing, that is, manipulating symbolic information. The language was based in part on the “lambda calculus” of Alonzo Church; the lambda calculus is a formal, applicative language with interesting theoretical properties. (Steven 1995)

When it was first developed, LISP embodied nine new ideas(Paul 2004). The nine ideas are, in order of their adoption by the mainstream,

  • Conditionals, an if-then-else construct.

  • A function type. In LISP,functions are a data type just like integers or strings. They have a literal representation, can be stored in variables, can be passed as argument, and so on.

  • Recursion. LISP was the first programming language to support it.

  • Dynamic typing.

  • Garbage-collection.

  • Programs composed of expressions. LISP programs are trees of expressions, each of which returns a value.

  • A symbol type.

  • A notation for code using trees of symbols and constants.

  • The whole language there all the time. There is no real distinction between read-time,compile-time, and run-time. You can compile or run code while reading, read or run code while compiling, and read or compile code at run time. Running code at read-time lets users reprogram LISP's syntax; running code at compile-time is the basis of macros;compiling at run time is the bases of LISP's use as an extension language in programs like Emacs; and reading at run time enables programs to communicate using s-expressions, an idea recently reinvented as XML.

LISP gives the programmer great flexibility and power. Data structures are created dynamically without need for the programmer to explicitly allocate memory. Declarations for data are not necessary. Using one basic data-structuring concept, the “S-expression”, both programs and data are easily represented.

Even though the language has matured in many ways over the years, list remain its central date type (David 1990). Every list has two forms: a printed representation and an internal one. In its printed form, a list is a brunch of items enclosed in parentheses. Inside the computer's memory, lists are organized as chains of cons cells.

The cons cells are linked together by pointers. Each cons cell has two pointers. One of them always points to an element of the list, while the other points to the next cons cell in the chain. When we say “list may include symbols or numbers as elements”, what we are really saying is that cons cells may contain pointers to symbols or numbers, as well as pointers to other cons cells.

Symbols are used for their object identity to name various entities in Common Lisp, including(but not limited to) linguistic entities such as variables and functions.(Link). Symbols have five attributes:

  • Name: The name of a symbol is a string used to identify the symbol.

  • Package: The object in this cell is called the home package of the symbol.

  • Property list: The property list is a symbol provides a mechanism for associating named attributes with that symbol.

  • Value: If a symbol has a value attribute, it is said to be bound. The object contained in the value cell of a bound symbol is the value of the global variable named by that symbol.

  • Function: If a symbol has a function attribute, it is said to be fbound. If the symbol is the name of a function in the global environment, the function cell contains the function. If the symbol is the name of either a macro in the global environment or a special operator, the symbol is fbound, but the object which the function cell contains is of implementation-dependent type and purpose.

In LISP, the syntax is defined as S-expression. S-expressions are defined recursively as either single data objects called “atoms” or lists of S-expressions. Number, arrays, character strings, and symbols are all atoms. The first element of every S-expression is an operator and any remaining elements are treated as data. Using symbols to represent variables and functions has great advantage. There are no obvious difference between programs and data, which makes it possible to write a program that can produce program and make use of its output.

  1. Power behind LISP

LISP was not really designed to be a programming language(Paul 2004). Who LISP is not obsolete is that it was not technology but math, and math doesn't get stale. The mathematical theories that support LISP are Turing machine, computability theory or recursion theory, lambda calculus,formal system, etc.

Turing machine is one example of the physical symbol system hypothesis mentioned in the first section. Alan Turing came up with the Turing machine, which he called “automatic machine”, by simulate the process that human solving problems. When human solves a problem which is written on a paper using pen, one look at the symbols on the paper and move the pen to some place on the paper to record something and come back later to check the record to make further conclusion.

A Turing machine consists of an infinite tape, and a read/write head connected to a control mechanism. The tape is divided into infinitely many cells, each of which contains a symbol from an alphabet called the tape alphabet; this alphabet includes the special symbol B to signify that a cell is blank(empty). The cells are scanned, one at a time, by the read/write head, which can move in both directions. At any given time, the machine(or, more precisely, its control mechanism) will be in one of a finite number of possible states. The behavior of the read/write head, and the change, if any, of the machine's state, are governed by the present state of the machine and by the symbol in the cell under scan(Douglas, 1994).

Reference

  1. David S. Touretzky. COMMONLISP:A Gentle Introduction to Symbolic Computation (Benjamin /Cummings ). 1990

  2. Douglas S. Bridges.Computability(Springer-Verlag). 1994

  3. Herbert A. Simon.Computers—Non-numerical computation. Applied MathematicalSciences, Vol. 77, No. 11, pp. 6264-6268, November 1980

  4. Paul Graham. Painters andHackers(O'REILLY). 2004

  5. Peter Seibel. Practical CommonLisp(Apress). 2005

  6. Steven L. Tanimoto. TheElements of Artificial intelligence Using Common Lisp(ComputerScience Press). 1995

  7. Common Lisp HyperSpec:http://www.lispworks.com/documentation/HyperSpec/Front/index.htm

原创粉丝点击