Special Topics: Programming Languages

Total Page:16

File Type:pdf, Size:1020Kb

Special Topics: Programming Languages Lecture #11 • 0 V22.0490.001 Special Topics: Programming Languages B. Mishra New York University. Lecture # 11 Programming Languages • MISHRA 2008 Lecture #11 • 1 —Slide 1— Common Lisp Language Survey 4 Functional Programming • Pure Functional Programming: Implicit Principle ◦ The value of an expression depends only on the values of its subexpressions, if any. – No side-effect. (No State—No assignment) – An expression has the same value, every time. – Implicit Storage Management: Allocation on Demand + Garbage Collection. – Functions are First Class Objects: 1) As value of an expression 2) As parameters 3) As data Objects. Programming Languages • MISHRA 2008 Lecture #11 • 2 —Slide 2— Common Lisp • LISP: LIst Processing Language Not— Lots of Insidious Sill Parentheses • Second oldest Programming Language (Af- ter Fortran) • Application Areas: 1. Theorem Proving 2. Symbolic Algebra 3. AI (Artificial Intelligence) (Natural Language Processing, Com- puter Vision, Robot Control Systems, Ex- pert Systems, Neural Networks, Automatic Programming) Programming Languages • MISHRA 2008 Lecture #11 • 3 —Slide 3— HISTORY • Developed at MIT AI Lab—1959. LISP 1.5 running on an IBM machine. • BBN LISP (PDP 1/SDS 940) became → INTERLISP (PDP 10) • MACLISP (MIT Project MAC) • LISP 1.6—A version of MACLISP ◦ UCI-LISP (Univ. of Cal. at Irvine) ◦ Standard Lisp (Univ. of Utah) • Lisp Machine Lisp Large Personal Lisp Machine built at MIT • FranzLISP for Vax/UNIX (UC Berkeley) • NIL for Vax/VMS (MIT) • Scheme at MIT • T Lisp at Yale Programming Languages • MISHRA 2008 Lecture #11 • 4 —Slide 4— Common Lisp • 1981/Carnegie-Mellon/Guy L. Steele • Clean Lisp Inconsistencies and illogical conventions were resolved • Transportable Programs written in Common Lisp and debugged in one implementation should run on another ma- chine/implementation without change. Programming Languages • MISHRA 2008 Lecture #11 • 5 —Slide 5— Lisp Data & Functional Objects • Lisp Programs and the data have Same form ◦ Self-modifying Lisp programs. ◦ Embedded languages in Lisp • Lisp functions are data objects that can be passed as parameters to other functions ◦ Extensible control structures • Interpreter + Compiler • Garbage Collector Programming Languages • MISHRA 2008 Lecture #11 • 6 —Slide 6— Lisp Objects • Lisp Objects 1. ATOMS (a) Numbers: {3, −5.7, 2010014567} (b) Symbols: { A, EVAL, PI, T, NIL } 2. CONS Conjunctions of two Lisp objects. Each of them may be a CONS object or an ATOM. • Example (CONS ’A ’B) (CONS ’2 (CONS ’BAD ’NIL)) Programming Languages • MISHRA 2008 Lecture #11 • 7 —Slide 7— CONS Cells = =Two Compartments... Each compartment holds an atom or a cons object (A pointer to a cons cell. (CONS 'B 'NIL) B NIL (B) (CONS 'A 'B) A B (A . B) (CONS '2 (CONS 'BAD 'NIL)) (2 BAD) 2 BAD NIL (CONS 'A (CONS (CONS 'B (CONS 'C 'NIL)) (CONS 'D NIL) ) A D NIL B C NIL (A (B C) D) Programming Languages • MISHRA 2008 Lecture #11 • 8 —Slide 8— LISTS • Function LIST (LIST ’A (LIST ’B ’C) ’D) => (A (B C) D) A D NIL B C NIL (A (B C) D) (LIST ’B NIL) => (B NIL) B NIL NIL (LIST) => NIL (An Atom not a CONS cell) Programming Languages • MISHRA 2008 Lecture #11 • 9 —Slide 9— Proper and Improper Lists • Proper Lists Lists terminating in NIL • Improper Lists Lists not terminating in NIL (A (B C) . D) A D B C NIL Programming Languages • MISHRA 2008 Lecture #11 • 10 —Slide 10— List Operations • CAR: Extracts the first element of a list • CDR: Extracts the rest (all but the first element) of a list • CAR & CDR can be applied to any list, but not to atom other than NIL (CAR NIL) ≡ (CDR NIL) ≡ NIL • Examples (CAR’(ABC)) =>A (CDR’(ABC)) =>(BC) (CAR (CDR (CAR (CDR ’(A (B C) D))))) => C Programming Languages • MISHRA 2008 Lecture #11 • 11 —Last Slide— List Predicates • Boolean-valued functions {T = True, NIL = False } • ATOM: True iff an atom (ATOM’NIL) => T (ATOM’(XY)) => NIL • CONSP, LISTP, ... • NULL: True iff an empty list (e.g., NIL) (NULL’NIL) => T (NULL’X) => NIL • ZEROP, NUMBERP, ... [End of Lecture #11] Programming Languages • MISHRA 2008.
Recommended publications
  • Introduction to Programming in Lisp
    Introduction to Programming in Lisp Supplementary handout for 4th Year AI lectures · D W Murray · Hilary 1991 1 Background There are two widely used languages for AI, viz. Lisp and Prolog. The latter is the language for Logic Programming, but much of the remainder of the work is programmed in Lisp. Lisp is the general language for AI because it allows us to manipulate symbols and ideas in a commonsense manner. Lisp is an acronym for List Processing, a reference to the basic syntax of the language and aim of the language. The earliest list processing language was in fact IPL developed in the mid 1950’s by Simon, Newell and Shaw. Lisp itself was conceived by John McCarthy and students in the late 1950’s for use in the newly-named field of artificial intelligence. It caught on quickly in MIT’s AI Project, was implemented on the IBM 704 and by 1962 to spread through other AI groups. AI is still the largest application area for the language, but the removal of many of the flaws of early versions of the language have resulted in its gaining somewhat wider acceptance. One snag with Lisp is that although it started out as a very pure language based on mathematic logic, practical pressures mean that it has grown. There were many dialects which threaten the unity of the language, but recently there was a concerted effort to develop a more standard Lisp, viz. Common Lisp. Other Lisps you may hear of are FranzLisp, MacLisp, InterLisp, Cambridge Lisp, Le Lisp, ... Some good things about Lisp are: • Lisp is an early example of an interpreted language (though it can be compiled).
    [Show full text]
  • High-Level Language Features Not Found in Ordinary LISP. the GLISP
    DOCUMENT RESUME ED 232 860 SE 042 634 AUTHOR Novak, Gordon S., Jr. TITLE GLISP User's Manual. Revised. INSTITUTION Stanford Univ., Calif. Dept. of Computer Science. SPONS AGENCY Advanced Research Projects Agency (DOD), Washington, D.C.; National Science Foundation, Washington, D.C. PUB DATE 23 Nov 82 CONTRACT MDA-903-80-c-007 GRANT SED-7912803 NOTE 43p.; For related documents, see SE 042 630-635. PUB TYPE Guides General (050) Reference Materials General (130) EDRS PRICE MF01/PCO2 Plus Postage. DESCRIPTORS *Computer Programs; *Computer Science; Guides; *Programing; *Programing Languages; *Resource Materials IDENTIFIERS *GLISP Programing Language; National Science Foundation ABSTRACT GLISP is a LISP-based language which provides high-level language features not found in ordinary LISP. The GLISP language is implemented by means of a compiler which accepts GLISP as input and produces ordinary LISP as output. This output can be further compiled to machine code by the LISP compiler. GLISP is available for several ISP dialects, including Interlisp, Maclisp, UCI Lisp, ELISP, Franz Lisp, and Portable Standard Lisp. The goal of GLISP is to allow structured objects to be referenced in a convenient, succinct language and to allow the structures of objects to be changed without changing the code which references the objects. GLISP provides both PASCAL-like and English-like syntaxes; much of the power and brevity of GLISP derive from the compiler features necessary to support the relatively informal, English-like language constructs. Provided in this manual is the documentation necessary for using GLISP. The documentation is presented in the following sections: introduction; object descriptions; reference to objects; GLISP program syntax; messages; context rules and reference; GLISP and knowledge representation languages; obtaining and using GLISP; GLISP hacks (some ways of doing things in GLISP which might not be entirely obvious at first glance); and examples of GLISP object declarations and programs.
    [Show full text]
  • The Evolution of Lisp
    1 The Evolution of Lisp Guy L. Steele Jr. Richard P. Gabriel Thinking Machines Corporation Lucid, Inc. 245 First Street 707 Laurel Street Cambridge, Massachusetts 02142 Menlo Park, California 94025 Phone: (617) 234-2860 Phone: (415) 329-8400 FAX: (617) 243-4444 FAX: (415) 329-8480 E-mail: [email protected] E-mail: [email protected] Abstract Lisp is the world’s greatest programming language—or so its proponents think. The structure of Lisp makes it easy to extend the language or even to implement entirely new dialects without starting from scratch. Overall, the evolution of Lisp has been guided more by institutional rivalry, one-upsmanship, and the glee born of technical cleverness that is characteristic of the “hacker culture” than by sober assessments of technical requirements. Nevertheless this process has eventually produced both an industrial- strength programming language, messy but powerful, and a technically pure dialect, small but powerful, that is suitable for use by programming-language theoreticians. We pick up where McCarthy’s paper in the first HOPL conference left off. We trace the development chronologically from the era of the PDP-6, through the heyday of Interlisp and MacLisp, past the ascension and decline of special purpose Lisp machines, to the present era of standardization activities. We then examine the technical evolution of a few representative language features, including both some notable successes and some notable failures, that illuminate design issues that distinguish Lisp from other programming languages. We also discuss the use of Lisp as a laboratory for designing other programming languages. We conclude with some reflections on the forces that have driven the evolution of Lisp.
    [Show full text]
  • Allegro CL User Guide
    Allegro CL User Guide Volume 1 (of 2) version 4.3 March, 1996 Copyright and other notices: This is revision 6 of this manual. This manual has Franz Inc. document number D-U-00-000-01-60320-1-6. Copyright 1985-1996 by Franz Inc. All rights reserved. No part of this pub- lication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means electronic, mechanical, by photocopying or recording, or otherwise, without the prior and explicit written permission of Franz incorpo- rated. Restricted rights legend: Use, duplication, and disclosure by the United States Government are subject to Restricted Rights for Commercial Software devel- oped at private expense as specified in DOD FAR 52.227-7013 (c) (1) (ii). Allegro CL and Allegro Composer are registered trademarks of Franz Inc. Allegro Common Windows, Allegro Presto, Allegro Runtime, and Allegro Matrix are trademarks of Franz inc. Unix is a trademark of AT&T. The Allegro CL software as provided may contain material copyright Xerox Corp. and the Open Systems Foundation. All such material is used and distrib- uted with permission. Other, uncopyrighted material originally developed at MIT and at CMU is also included. Appendix B is a reproduction of chapters 5 and 6 of The Art of the Metaobject Protocol by G. Kiczales, J. des Rivieres, and D. Bobrow. All this material is used with permission and we thank the authors and their publishers for letting us reproduce their material. Contents Volume 1 Preface 1 Introduction 1.1 The language 1-1 1.2 History 1-1 1.3 Format
    [Show full text]
  • A Note on the Optimal Allocation of Spaces in MACLISP by Henry C
    MASSACHUSETTS INSTITUTE OF TECHNOLOGY ARTIFICIAL INTELLIGENCE LABORATORY Al Working Paper 142 March 16, 1977 A Note on the Optimal Allocation of Spaces in MACLISP by Henry C. Baker, Jr. This note describes a method for allocating storage among the various spaces in the MACLISP Implementation of LISP. The optimal strategy which minimizes garbage collector effort allocates free storage among the various spaces in snch a way that they all run out at the same time. In an equilibrium situation, this corresponds to allocating free storage to the spaces in proportion to their usage. Methods are investigated by which the rates of usage can be inferred, and a ge-daemon interrupt handler is developed which implements an approximately optimal strategy in MACLISP. Finally, the sensitivity of this method to rapidly varying differential rates of cell usage is discussed. Key Words and Phrases: garbage collection, list processing, virtual memory, storage management, storage allocation, LISP. CR Categories: 3.50, 3.60, 3.73, 3.80, 4.13, 422, 4.32, 4.33, 4.35, 4.49 This report describes research done at the Artificial Intelligence Laboratory of the Massachusetts Institute of Technology. Support for the laboratory's artificial intelligence research is provided in part by the Advanced Research Projects Agency of the Department of Defense under Office of Naval Research contract N00014-75-C-0522. Working Papers are informal papers intended for internal use. March 16, 1977 A Note on the Optimal Allocation of Spaces in MACLISP Henry C. Baker, Jr. MACLISP [11 unlike some other implementations of. LISP, allocates storage for different types of objects in non-contiguous areas called spaces.
    [Show full text]
  • History of the Lisp Language
    History of the Lisp Language History of the Lisp Language The following information is derived from the history section of dpANS Common Lisp. Lisp is a family of languages with a long history. Early key ideas in Lisp were developed by John McCarthy during the 1956 Dartmouth Summer Research Project on Artificial Intelligence. McCarthy’s motivation was to develop an algebraic list processing language for artificial intelligence work. Implementation efforts for early dialects of Lisp were undertaken on the IBM 704, the IBM 7090, the Digital Equipment Corporation (DEC) PDP−1, the DEC PDP−6, and the PDP−10. The primary dialect of Lisp between 1960 and 1965 was Lisp 1.5. By the early 1970’s there were two predominant dialects of Lisp, both arising from these early efforts: MacLisp and Interlisp. For further information about very early Lisp dialects, see The Anatomy of Lisp or Lisp 1.5 Programmer’s Manual. MacLisp improved on the Lisp 1.5 notion of special variables and error handling. MacLisp also introduced the concept of functions that could take a variable number of arguments, macros, arrays, non−local dynamic exits, fast arithmetic, the first good Lisp compiler, and an emphasis on execution speed. For further information about Maclisp, see Maclisp Reference Manual, Revision 0 or The Revised Maclisp Manual. Interlisp introduced many ideas into Lisp programming environments and methodology. One of the Interlisp ideas that influenced Common Lisp was an iteration construct implemented by Warren Teitelman that inspired the loop macro used both on the Lisp Machines and in MacLisp, and now in Common Lisp.
    [Show full text]
  • Report on Common Lisp to the Interlisp Community
    Masinter & vanMelle on CommonLisp, circa Dec 1981. Subject: Report on Common Lisp to the Interlisp Community Introduction What is Common Lisp? Common Lisp is a proposal for a new dialect of Lisp, intended be implemented on a broad class of machines. Common Lisp is an attempt to bring together the various implementors of the descendents of the MacLisp dialect of Lisp. The Common Lisp effort is apparently an outgrowth of the concern that there was a lack of coordination and concerted effort among the implementors of the descendents of MacLisp. Common Lisp's principal designers come from the implementors of Lisp Machine Lisp (at MIT and Syrnbolics), Spice Lisp (at CMU), NIL (both a VAX implementation at MIT and the S-1 implementation at Lawrence Livermore), and MacLisp (at MIT, of course.) Also contributing, but not strongly represented, are Standard Lisp (at Utah) and Interlisp (at PARC, BBN and ISI.) Programs written entirely in Common Lisp are supposed to be readily run on any machine supporting Common Lisp. The language is being designed with the intent first of creating a good language, and only secondarily to be as compatible as practical with existing dialects (principally Lisp Machine Lisp.) Common Lisp attempts to draw on the many years of experience with existing Lisp dialects; it tries to avoid constructs that are obviously machine-dependent, yet include constructs that have the possibility of efficient implementation on specific machines. Thus, there are several different goals of Common Lisp: (1)to profit from previous experience in Lisp systems, (2) to make efficient use of new and existing hardware, and (3) to be compatible with existing dialects.
    [Show full text]
  • Large-Scale System Development in Several Lisp Environments!
    LARGE-SCALE SYSTEM DEVELOPMENT IN SEVERAL LISP ENVIRONMENTS! Sanjal Naraln, David McArthur and Philip Klahr The Rand Corporation 1700 Main Street Santa Monica, California 90406 USA ABSTRACT The other main problem with the Maclisp implementation was that it resided on a DEC-20. This machine is proving increasingly ROSS |7] is an object-oriented language developed for building inadequate for large AI programs, because of its small 18-bit address knowledge-based simulations [4l. SWIRL |5, 6] is a program written space. in ROSS that embeds knowledge about defensive and offensive air battle strategies. Given an initial configuration of military forces, 2.2. Franrllsp on a VAX-11/780 [2] SWIRL simulates the resulting air battle. We have implemented ROSS and SWIRL in several different Lisp environments. We Because of Franzlisp's advertised compatibility with Maclisp, we report upon this experience by comparing the various environments thought it would be straightforward to convert our Maclisp versions in terms of cpu usage, real-time usage, and various user aids. of ROSS and SWIRL to work within the Franzlisp environment. This was almost the case. About two man-weeks of effort over a 1. INTRODUCTION one month period was required for the conversion process. We did notice certain inconsistencies between Franzlisp and Maclisp but Over the past six months we have been engaged in implementing they were fairly easy to fix. Although ROSS and SWIRL are large ROSS (an object-oriented, know ledge-based simulation language [7jj systems even when compiled (see Table 1), they ran acceptably fast and SWIRL (an air battle simulation [5, 6]) in five different Lisp within Franzlisp, even when running large simulations.
    [Show full text]
  • Evolution of Emacs Lisp
    Evolution of Emacs Lisp STEFAN MONNIER, Universit´ede Montr´eal,Canada MICHAEL SPERBER, Active Group GmbH, Germany While Emacs proponents largely agree that it is the world's greatest text editor, it is almost as much a Lisp machine disguised as an editor. Indeed, one of its chief appeals is that it is programmable via its own programming language, Elisp (or Emacs Lisp), a Lisp in the classic tradition. In this article, we present the history of this language over its more than 30 years of evolution. Its core has remained remarkably stable since its inception in 1985, in large part to preserve compatibility with the many third-party packages providing a multitude of extensions. Still, Elisp has evolved and continues to do so. Despite the fact that it is closely tied to a concrete editor, Elisp has spawned multiple implementations| in Emacs itself but also in variants of Emacs, such as XEmacs, Edwin, and even the window manager Sawfish. Through competing implementations as well as changes in maintainership, it has pickedup outside influences over the years, most notably from Common Lisp. Important aspects of Elisp have been shaped by concrete requirements of the editor it supports, such as the buffer-local variables that tie bindings to editing contexts, as well as implementation constraints. These requirements led to the choice of a Lisp dialect as Emacs's language in the first place, specifically its simplicity and dynamic nature: Loading additional Emacs packages or changing the ones in place occurs frequently, and having to restart the editor in order to re-compile or re-link the code would be unacceptable.
    [Show full text]
  • Common Lisp Objects for Xemacs Didier Verna
    CLOX: Common Lisp Objects for XEmacs Didier Verna To cite this version: Didier Verna. CLOX: Common Lisp Objects for XEmacs. ELS 2010 European Lisp Symposium 2010, May 2010, Lisbon, Portugal. hal-01543381 HAL Id: hal-01543381 https://hal.archives-ouvertes.fr/hal-01543381 Submitted on 26 Jun 2017 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. CLOX: Common Lisp Objects for XEmacs Didier Verna (Epita Research and Development Laboratory, Paris, France [email protected]) Abstract CLOX is an ongoing attempt to provide a full Emacs Lisp implementation of the Common Lisp Object System, including its underlying meta-object protocol, for XEmacs. This paper describes the early development stages of this project. CLOX currently consists in a port of Closette to Emacs Lisp, with some additional features, most notably, a deeper integration between types and classes and a comprehensive test suite. All these aspects are described in the paper, and we also provide a feature comparison with an alternative project called Eieio. Key Words: Lisp, Object Orientation, Meta-Object Protocol Category: D.1.5, D.3.3 1 Introduction Note: the author is one of the core maintainers of XEmacs.
    [Show full text]
  • COMMON LISP: a Gentle Introduction to Symbolic Computation COMMON LISP: a Gentle Introduction to Symbolic Computation
    COMMON LISP: A Gentle Introduction to Symbolic Computation COMMON LISP: A Gentle Introduction to Symbolic Computation David S. Touretzky Carnegie Mellon University The Benjamin/Cummings Publishing Company,Inc. Redwood City, California • Fort Collins, Colorado • Menlo Park, California Reading, Massachusetts• New York • Don Mill, Ontario • Workingham, U.K. Amsterdam • Bonn • Sydney • Singapore • Tokyo • Madrid • San Juan Sponsoring Editor: Alan Apt Developmental Editor: Mark McCormick Production Coordinator: John Walker Copy Editor: Steven Sorenson Text and Cover Designer: Michael Rogondino Cover image selected by David S. Touretzky Cover: La Grande Vitesse, sculpture by Alexander Calder Copyright (c) 1990 by Symbolic Technology, Ltd. Published by The Benjamin/Cummings Publishing Company, Inc. This document may be redistributed in hardcopy form only, and only for educational purposes at no charge to the recipient. Redistribution in electronic form, such as on a web page or CD-ROM disk, is prohibited. All other rights are reserved. Any other use of this material is prohibited without the written permission of the copyright holder. The programs presented in this book have been included for their instructional value. They have been tested with care but are not guaranteed for any particular purpose. The publisher does not offer any warranties or representations, nor does it accept any liabilities with respect to the programs. Library of Congress Cataloging-in-Publication Data Touretzky, David S. Common LISP : a gentle introduction to symbolic computation / David S. Touretzky p. cm. Includes index. ISBN 0-8053-0492-4 1. COMMON LISP (Computer program language) I. Title. QA76.73.C28T68 1989 005.13'3±dc20 89-15180 CIP ISBN 0-8053-0492-4 ABCDEFGHIJK - DO - 8932109 The Benjamin/Cummings Publishing Company, Inc.
    [Show full text]
  • Csc 372 [0.5Cm] Comparative Programming Languages [0.5Cm] 35
    CSc 372 Comparative Programming Languages 35 : Scheme — History Department of Computer Science University of Arizona [email protected] Copyright c 2013 Christian Collberg 1/22 History of the Lisp Language http://www.apl.jhu.edu/~hall/text/Papers/Brief-History-of-Lisp.ps The following information is derived from the history section of dpANS Common Lisp. Lisp is a family of languages with a long history. Early key ideas in Lisp were developed by John McCarthy during the 1956 Dartmouth Summer Research Project on Artificial Intelligence. McCarthy’s motivation was to develop analgebraic list processing language for artificial intelligence work. Implementation efforts for early dialects of Lisp were undertaken on the IBM 704, the IBM 7090, the Digital Equipment Corporation (DEC) PDP-1, the DECPDP-6, and the PDP-10. The primary dialect of Lisp between 1960 and 1965 was Lisp 1.5. By the early 1970’s there were two predominant dialects of Lisp, both arising from these early efforts: MacLisp and Interlisp. Forfurther information about very early Lisp dialects, see The Anatomy of Lisp or Lisp 1.5 Programmer’s Manual. 2/22 History of the Lisp Language. MacLisp improved on the Lisp 1.5 notion of special variables and error handling. MacLisp also introduced theconcept of functions that could take a variable number of arguments, macros, arrays, non-local dynamic exits, fast arithmetic, the first good Lisp compiler, and an emphasis on execution speed. Interlisp introduced many ideas into Lisp programming environments and methodology. One of the Interlisp ideasthat influenced Common Lisp was an iteration construct implemented by Warren Teitelman that inspired the loop macro used both on the Lisp Machines and in MacLisp, and now in Common Lisp.
    [Show full text]