Programming Languages Interlisp
Total Page:16
File Type:pdf, Size:1020Kb
PROGRAMMING LANGUAGES INTERLISP SUBMITTED BY: DIVYA BHOJ RISHISH CHANDRA 2 HISTORY: Interest in artificial intelligence first surfaced in the mid 1950. Linguistics, psychology, and mathematics were only some areas of application for AI. Linguists were concerned with natural language processing, while psychologists were interested in modeling human information and retrieval. Mathematicians were more interested in automating the theorem proving process. The common need among all of these applications was a method to allow computers to process symbolic data in lists. IBM was one of the first companies interested in AI in the 1950s. At the same time, the FORTRAN project was still going on. Because of the high cost associated with producing the first FORTRAN compiler, they decided to include the list processing functionality into FORTRAN. The FORTRAN List Processing Language (FLPL) was designed and implemented as an extention to FORTRAN. In 1958 John McCarthy took a summer position at the IBM Information Research Department. He was hired to create a set of requirements for doing symbolic computation. The first attempt at this was differentiation of algebraic expressions. This initial experiment produced a list of of language requirements, most notably was recursion and conditional expressions. At the time, not even FORTRAN (the only high-level language in existance) had these functions. It was at the 1956 Dartmouth Summer Research Project on Artificial Intelligence that John McCarthy first developed the basics behind Lisp. His motivation was to develop a list processing language for Artificial Intelligence. By 1965 the primary dialect of Lisp was created (version 1.5). By 1970 special-purpose computers known as Lisp Machines, were designed to run Lisp programs. 1980 was the year that object-oriented concepts were integrated into the language. By 1986, the X3J13 group formed to produce a draft for ANSI Common Lisp standard. Finally in 1992, X3J13 group published the American National Standard for Common Lisp. The key feature of the Lisp family is that they all are late-bound languages that use parentheses as the basic delimiter of evaluation forms, and all forms are expressions without exception. The uniform syntax turned out to allow the use of metaprogramming through manipulation (via macros) of the list-representation of this syntax, called symbolics expressions, or S-Expressions for short (even shorter, "SEXP"). 2 3 Lisp is also defined as a program in itself: (loop (print (eval (read)))), called the read- eval-print loop. LISP stands for LISt Processing.INTERLISP is a dialect of Lisp developed in 1967 by Bolt, Beranek and Newman (Cambridge, MA) as a descendant of BBN-Lisp. It emphasises user interfaces. It is currently supported by Xerox PARC. INTRODUCTION: Interlisp was once one of two main branches of LISP (the other being MACLISP). In 1981 Common LISP was begun in an effort to combine the best features of both. Interlisp includes a Lisp programming environment. It is dynamically scoped. NLAMBDA functions do not evaluate their arguments. Any function could be called with optional arguments. Machine code can be intermixed with interlisp expressions via the assemble directive of the compiler.the compiler also contains a facility for “block compilation” which allows a group of functions to be compiled as a unit suppressing internal names.Each successive level of computation,from interpreted through compiled,to block- compiled provides greater speed at a cost of debugging ease. Interlisp has been designed to be a good on-line interactive system.Some of the features provided include elaborate debugging facilities with tracing and conditional brealpoints and a sophisticated LISP oriented editor within the system.Utilization of a uniform error processing through user accessible routines has allowed the implementation of DWIM – “Do-what-I-mean” facility,which automatically corrects many types of errors without losing the context of computation. DATA TYPES: INTERLISP operates in an 18-bit address space. This address space is divided into 512 word pages with a limit of 512 pages, or 262,144 words , but only that portion of address space currently in use actually exists on any storage medium. INTERLISP itself and all data storage are contained within this address space. A pointer to a data element such as a number, atom , etc., is simply the address of the data element in this 18-bit address space. The data types of interlisp are lists, atoms, pnames , arrays, large and small integers, floating point numbers, string characters and string pointers. Compiled code and hash 3 4 arrays are currently included with arrays. Here is a brief description of each of the data types that are used in interlisp. 1. LITERAL ATOM: A literal atom is input as any string of non-delimiting characters that cannot be interpreted as a number.The syntactic characters that delimit atoms are space,end- of-line,line feed.%( ) “ ] and ].However, these characters may be included in atoms by preceding them with the escape character %.Literal atoms are printed by print and prin2 as a sequence of characters with %’s inserted before all delimiting characters(so that the atom will read back in properly. 2. PNAMES: The pnames of atoms,pointed to in the third word of the atom,comprise another data type with storage assigned as it is needed.this data type only occurs as a component of an atom or a strinh.It does not appear ,for example as an element of a list.Pnames have no input syntax or output format as they can be directly referenced by user programs.A pname is a sequence of 7 bit characters packed 5 to a word ,beginning at a word boundary.The first character of a pname contains its length,thus the maximum length of a pname is 126 characters. 3. NUMERICAL ATOMS: Numerical atoms ,or simply numbers ,do not have property lists ,value cells ,functions definition cells ,or explicit pnames .There are currently two types of numbers in INTERLISP: integers ,and floating point numbers. Integer: An integer is stored in one 36 bit word;thus its magnitude must be less than 2+(35^7) .To avoid having to store(and hence garbage collect) the values of small integers,a few pages of address space ,overlapping the INTERLISP machine language code,are reserved for their representation.The small number pointer itself,minusa constant,is the value of the number.Currently the range of 4 5 ‘small’integers is –1536 through +1535.The predicate smallp is used to test whether an integer is ‘small’. Floating Point Number: A floating point number is input as a signed integer ,followed by a decimal point ,followed by another sequence of digits called the fraction ,followed by an exponent (represented by E followed by a signed integer).Both signs are optional ,and either the fraction following the decimal point ,or the integer preceding the decimal point may be omitted .One or the other of the decimal point or exponent may also be omitted ,but at least one of them must be present to distinguish a floating point number from an integer. 4. LIST’s: The input syntax for a list is a sequence (at least one) of INTERLISP data elements ,e.g literal atoms ,other lists ,etc. enclosed in parentheses or brackets .A bracket can be used to terminate several lists .If there are 2 or more elements in a list, the final element can be preceded by a . (Delimited on both sides), indicating that cdr of the final node in the list is to be the element immediately following the.,e.g. (A.B) or (A B C . D), otherwise cdr of the last node in a list will be NIL. 5. ARRAY: An array in interlisp is a one-dimensional block of contiguous storage of arbitrary length. Arrays do not have input syntax; they can only be created by the function array. Arrays are printed by both print, prin2, and prin1 as # followed by the address of the array pointer (in octal). Array elements can be referenced by the functions elt and elt, and set by the functions seta and setd. 6. STRING: The input syntax for a string is a “, followed by a sequence of any characters except “ and %, terminated by a “.” and % may be included in a string by proceeding them with the escape character %. An array in interlisp is a one 5 6 dimensional block of contiguous storage of arbitrary length. Arrays do not have input syntax: they can only be created by the function array. FUNCTION TYPES: In INTERLISP, each function may independently have: • Its arguments evaluated or not evaluated. • A fixed number of arguments or an indefinite number of arguments. • Be defined by an INTERLISP expression, by built-in machine code, or by compiled machine code. Hence there are twelve function types (2 * 2 * 3). Exprs: Functions defined by interlisp expressions are called exprs. Exprs must begin with either LAMBDA or NLAMBDA indicating whether whether the arguments to the function are to be evaluated or not evaluated, respectively. Compiled Functions: The INTERLISP compiler can compile functions defined by expressions. Functions may also written directly in machine code the ASSEMBLE directive of the compiler. Functions created by the compiler, whether from S-expressions or ASSEMBLE directives. Function Type: The function fntype returns the function type of its argument .The value of fntype is one of the following 12 types: 6 7 EXPR CEXPR SUBR FEXPR CFEXPR FSUBR EXPR* CEXPR* SUBR* FEXPR* CFEXPR* FSUBR* Progn progn is a function of an arbitrary number of arguments .prong evaluates the arguments in order and returns the value of the last ,i.e. it is an extension of the function prog2 of LISP .Both cond and lambda/nlambda expressions have been generalized to permit ‘implicit progns’.