COMMOM OBJECT ORIENTED LISP SYSTEMS

Similar documents
2. Reasons for implementing clos-unit

The Design and Implementation of a Modern Lisp. Dialect

Section 10: LISP to Scheme. Evolution of Software Languages

Allegro CL Certification Program

Scheme: Expressions & Procedures

PROGRAMMING LANGUAGES

Common Lisp Object System Specification. 1. Programmer Interface Concepts

Heap storage. Dynamic allocation and stacks are generally incompatible.

Basics of Programming with Python

Functional Programming. Big Picture. Design of Programming Languages

Week 2: The Clojure Language. Background Basic structure A few of the most useful facilities. A modernized Lisp. An insider's opinion

A Brief Introduction to Common Lisp

Modern Programming Languages. Lecture LISP Programming Language An Introduction

8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES

FUNKCIONÁLNÍ A LOGICKÉ PROGRAMOVÁNÍ 2. ÚVOD DO LISPU: ATOMY, SEZNAMY, FUNKCE,

INF4820: Algorithms for Artificial Intelligence and Natural Language Processing. Common Lisp Fundamentals

Instances and Classes. SOFTWARE ENGINEERING Christopher A. Welty David A. Ferrucci. 24 Summer 1999 intelligence

Scripting Languages TCL: Tool Command Language

Functional Languages. CSE 307 Principles of Programming Languages Stony Brook University

Scheme Datatypes. expressions. pairs. atoms. lists. symbols. booleans

Object Oriented Programming (OOP)

EAS230: Programming for Engineers Lab 1 Fall 2004

Symbolic Reasoning. Dr. Neil T. Dantam. Spring CSCI-561, Colorado School of Mines. Dantam (Mines CSCI-561) Symbolic Reasoning Spring / 86

Chapter 11 :: Functional Languages

Artificial Intelligence Lecture 1

A Small Interpreted Language

Robot Programming with Lisp

CS 314 Principles of Programming Languages

Have examined process Creating program Have developed program Written in C Source code

What is a programming language?

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s

Lisp to Ruby to Rubinius

Functional Programming

Tutorial 12 Craps Game Application: Introducing Random Number Generation and Enumerations

Language Translation, History. CS152. Chris Pollett. Sep. 3, 2008.

SYSPRO s Fluid Interface Design

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation

Programming Language Pragmatics

Why are there so many programming languages? Why do we have programming languages? What is a language for? What makes a language successful?

CS508-Modern Programming Solved MCQ(S) From Midterm Papers (1 TO 22 Lectures) BY Arslan

Introduction to Functional Programming

Week 5: Background. A few observations on learning new programming languages. What's wrong with this (actual) protest from 1966?

Functional Programming

Design & Implementation Overview

Class Structure. Prerequisites

Organization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?

LINDA. The eval operation resembles out, except that it creates an active tuple. For example, if fcn is a function, then

Outline. Program development cycle. Algorithms development and representation. Examples.

White Paper. The Benefits of Object-Based Architectures for SCADA and Supervisory Systems. What s Inside:

Introduction to lambda calculus Part 3

plisp: A Friendly Lisp IDE for Beginners Rajesh Jayaprakash Tata Consultancy Services Chennai, India

PROGRAMMING LANGUAGE PARADIGMS & THE MAIN PRINCIPLES OF OBJECT-ORIENTED PROGRAMMING

Simple Dynamic Compilation with GOO. Jonathan Bachrach. MIT AI Lab 01MAR02 GOO 1

(Python) Chapter 3: Repetition

Exam in TDDB84: Design Patterns,

INF4820: Algorithms for Artificial Intelligence and Natural Language Processing. More Common Lisp

Check out how to use the random number generator (introduced in section 4.11 of the text) to get a number between 1 and 6 to create the simulation.

Functional Programming. Pure Functional Languages

Common LISP Tutorial 1 (Basic)

Dynamic Object-Oriented Programming with Smalltalk 1. Introduction

Chapter 1 INTRODUCTION SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC.

Lisp. Versions of LISP

Introduction to LISP. York University Department of Computer Science and Engineering. York University- CSE V.

COSI: Adding Constraints to the object-oriented paradigm

Functional programming in LISP

Announcements. Written Assignment 2 due today at 5:00PM. Programming Project 2 due Friday at 11:59PM. Please contact us with questions!

Introduction to Functional Programming

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

Defining Domain-Specific Modeling Languages

6.001 Notes: Section 8.1

Introduce C# as Object Oriented programming language. Explain, tokens,

Symbolic Computation and Common Lisp

Type Checking in COOL (II) Lecture 10

Scheme: Data. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, Glenn G.

COMP 110 Programming Exercise: Simulation of the Game of Craps

Combined Object-Lambda Architectures

Functional Programming. Pure Functional Languages

An Introduction to Software Engineering. David Greenstein Monta Vista High School

Introduction. A. Bellaachia Page: 1

SML: Specialized Matrix Language White Paper

The Benefits of Component Object- Based SCADA and Supervisory System Application Development

How Developers Use the Dynamic Features of Programming Languages: The Case of Smalltalk

In the hardware module, you saw the basic execution of a program Programs are written in specific languages Each language has it s strengths and

Ancient System of Operations: Computing with Mathematical Devices. By: Calvin L. Fitts Jr. History of Mathematics. Ms.

Dr M Kasim A Jalil. Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson)

CS 360 Programming Languages Interpreters

Functional Programming with Common Lisp

Program Development. Program Development. A Foundation for Programming. Program Development

CPSC 427: Object-Oriented Programming

Welcome to. Instructor Marc Pomplun CS 470/670. Introduction to Artificial Intelligence 1/26/2016. Spring Selectivity in Complex Scenes

Safe and Secure Software. Ada An Invitation to. Conclusion. Courtesy of. John Barnes. The GNAT Pro Company


Allegro CL Certification Program

STUDENT LESSON A14 Boolean Algebra and Loop Boundaries

CS 415 Midterm Exam Fall 2003

Page 1. Human-computer interaction. Lecture 1b: Design & Implementation. Building user interfaces. Mental & implementation models

C++ (Non for C Programmer) (BT307) 40 Hours

Ten Reasons to Optimize a Processor

Introduction to Programming

Object-oriented Compiler Construction

Transcription:

COMMOM OBJECT ORIENTED LISP SYSTEMS HISTORY: 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. 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. 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. One of the most important developments in Lisp occurred during the second half of the 1970's: Scheme. Scheme, designed by Gerald J. Sussman and Guy L. Steele Jr., is a simple dialect of Lisp whose design brought to Lisp some of the ideas from programming language semantics developed in the 1960's. In the late 1970's object-oriented programming concepts started to make a strong impact on Lisp. At MIT, certain ideas from Smalltalk made their way into several widely used programming systems. Flavors, an object-oriented programming system with multiple inheritance was developed at MIT for the Lisp machine community by Howard Cannon and others. At Xerox, the experience with Smalltalk and Knowledge Representation Language (KRL led to the development of Lisp Object Oriented Programming System (LOOPS and later Common LOOPS. These systems influenced the design of the Common Lisp Object System (CLOS. CLOS was developed specifically for X3J13's standardization effort, and was separately written up in common object oriented Lisp systems specifications. However, minor details of its design have changed slightly since that publication. In April 1981,

after a DARPA-sponsored meeting concerning the splintered Lisp community, Symbolics, the SPICE project, the NIL project, and the S-1 Lisp project joined together to define Common Lisp. Initially spearheaded by White and Gabriel, the driving force behind this grassroots effort was provided by Fahlman, Daniel Weinreb, David Moon, Steele, and Gabrie. In 1986 X3J13 was formed as a technical working group to produce a draft for an ANSI Common Lisp standard. Because of the acceptance of Common Lisp, the goals of this group differed from those of the original designers. These new goals included stricter standardization for portability, an object-oriented programming system, a condition system, iteration facilities, and a way to handle large character sets. To accommodate those goals, a new language specification was developed. CLOS (Common Lisp Object System is a dynamic, object oriented extension to Common Lisp that provides a powerful general purpose programming language. It is a popular tool for development of large scale systems. The value of CLOS is becoming more widely recognized today, based on it features and its very modern object system approach, supporting features such as the following: 1. Support for modules (or packages, preventing name clashes 2. A unified syntax derived from Common Lisp: a. A multiple inheritance scheme b. Generic function calls and message passing c. A combination of methods related to function composition d. Class re-definitions and updating e. Relationships between generic functions through a "meta object protocol" Integration with Windows and with native operating systems and with other languages such as C is straightforward. CLOS offers an "open world" approach to systems development, and supports optimization for speed. CLOS is a very modern dynamic, principled, object-oriented, class-centered, method-centered approach to tailoring a system. It offers a major benefit of reducing the turn-around time for development. This means you can get your applications to market faster, and often at lower programming costs. It also means it is faster and easier to make changes to your applications for example, to

provide upgrades. For example, in the course of debugging a system you can look and realize you didn't write a class correctly. So right on the spot you can say "redefine the class" and it all happens dynamically--the system adjusts on the fly. You don't have to go back to ground zero and recompile all the dependency chains that are dependent on that class definition and so on (there could be hundreds or thousands of them. The whole point of the object oriented approach is to take something and to customize it without having to change the code, without having to go back and edit any of the lines of code that already exist. Objectivity allows someone who doesn't have access to your source code to extend the functionality of functions that you have written without being forced to become involved in the details of the program you provided them. Users don't have to change their source code to use your extensions. This opens up the use of whole worlds of off-the-shelf class libraries of functionality. CLOS also offers the capability of enabling your instances (or objects in general to live from session to session. This powerful capability enables you to have your objects "persist" so that they may be returned as the result of a function or procedural call. The object may be the value of a function parameter or returned as a functional value. This capability allows you to make subclasses of a standard class that has the behavior you desire. It also enables your LISP functions to create new functions at runtime or alter old ones, depending on other parameters, saving significant amounts of programming time. Some developers feel that Smalltalk's object model is too restrictive, making system optimization quite difficult in many applications. For example, Smalltalk lacks multiple inheritance, which CLOS offers. CLOS also offers multi-methods (or Mixins, which enable a much more concise expression of problems, which in turn is very important to incremental development. Smalltalk's GUI framework dates back long before current GUI approaches, which can make it difficult to integrate Smalltalk into current GUI approaches. These are examples of why some experienced developers feel LISP with CLOS is a significantly more robust environment than other object oriented languages can offer. Because of the standards that exist for CLOS, it is much easier to port CLOS code than when using code from less mature object oriented languages.

It is also interesting to note that a functional language (such as LISP with CLOS is inherently well suited for parallel processing. If a function is free of side effects, values for the various variables can be computed independently and simultaneously. A programmer using a functional language need not give extraordinary thought to parallelism but simply program functions. A smart compiler will pick out which parameters should be evaluated in parallel. Thousands of new users are beginning to experience for the first time the benefits of the power and flexibility offered by dynamic object oriented programming environments enhanced by the addition of CLOS. This program simply demonstrates the return of a string from a function call, in the Lisp programming language. The program will display the message "Hello world" each time the function HELLO is called. Source Code ;;; HWorld.lsp ;;; =========== ;;; =========== HELLO WORLD SIMULATION ============== ;;; ;;; =========== ;;; This function simply returns the string Hello World that is in quotes. (DEFUN HELLO ( "HELLO WORLD" WORKS CITED Touretzky, David. " LISP: A GENTLE INTRODUCTION TO SYMBOLIC COMPUTATION" HARPER AND ROW, PUBLISHERS, New York 1984.

;;; CrapsSim.lsp ;;; The main purpose of this program was to implement a Craps game, using a language that we have just learned. Also, it was written in a functional style with almost no reliance on the assignment operation. Only one local variable called THROW was CRAPS SIMULATION ;;; ** This function takes no parameters as input and returns a random number between 1 and 6. ** (DEFUN THROW-DIE ( (+ (RANDOM 6 1 ;;; get a random number between 0 and 5 and then add 1 ;;; ;;; ** This function takes no parameters as input and returns a LIST with two numbers between 1 and 6. ** ( DEFUN THROW-DICE ( (LIST (THROW-DIE (THROW-DIE ;;; create a list with two random numbers

;;; ;;; ** This function takes two numbers as parameters for input and returns T or Nil. T is returned if both;;; numbers are equal to 6. Nil is returned otherwise. ** (DEFUN BOXCARS-P (A B (AND (EQUAL '6 A (EQUAL '6 B ;;; ;;; ** This function takes two numbers as parameters for input and returns T or Nil. T is returned if both;;; numbers are equal to 1. Nil is returned otherwise. ** (DEFUN SNAKE-EYES-P (A B (AND (EQUAL '1 A (EQUAL '1 B

;;; ;;; ** This function takes two numbers as parameters for input and returns T or Nil. T is returned if the;;; sum of both numbers is equal to a 7 or 11. Nil is returned otherwise. ** (DEFUN INSTANT-WIN-P (A B (OR (EQUAL '7 (+ A B (EQUAL '11 (+ A B ;;; ;;; ** This function takes two numbers as parameters for input and returns T or Nil. T is returned if the ;;; sum of both numbers is equal to a 2, 3 or 12. Nil is returned otherwise. ** (DEFUN INSTANT-LOSS-P (A B (OR (EQUAL '2 (+ A B (EQUAL '3 (+ A B (EQUAL '12 (+ A B

;;; ;;; ** This function takes two numbers as parameters for input and returns a string. If function BOXCARS_P;;; returns T, then the returned string equals BOXCARS. If function SNAKE_EYES_P returns T, then the ;;; returned string equals SNAKE_EYES. The string contains Nil otherwise. ** (DEFUN SAY-THROW (A B (COND ((BOXCARS-P A B 'BOXCARS BOXCARS_P ((SNAKE-EYES-P A B 'SNAKE-EYES SNAKE_EYES_P ;;; make use of function ;;; make use of function ;;; ==================== ;;; ** This is the main function used to simulate the game of craps. Variable THROW contains a LIST of two;;; numbers between 1 and 6. The numbers located in THROW, are used as parameters for the other functions.;;; The several pieces used for output are listed together and then the LIST is returned from this ;;; function. (DEFUN CRAPS (

(LET THROW (THROW-DICE ;;; if roll is a win, then LIST the appropriate output ;;; get initial roll of the dice (COND ((INSTANT-WIN-P (FIRST THROW (SECOND THROW (LIST 'THROW (FIRST THROW 'AND (SECOND THROW '-- (+ (FIRST THROW (SECOND THROW '-- 'YOU 'WIN ;;; if roll is a loss, then check for BOXCARS or SNAKE-EYES ((INSTANT-LOSS-P (FIRST THROW (SECOND THROW (IF (EQUAL 'NIL (SAY-THROW (FIRST THROW (SECOND THROW ;;; if Nil then LIST appropriate output (LIST 'THROW (FIRST THROW 'AND (SECOND THROW '-- (+ (FIRST THROW (SECOND THROW '-- 'YOU 'LOSE ;;; else include the BOXCARS or SNAKE-EYES string in the output (LIST 'THROW (FIRST THROW 'AND (SECOND THROW '-- (SAY- THROW (FIRST THROW (SECOND THROW '-- 'YOU 'LOSE ;;; if roll is not instant win or loss then output sum of dice (T (LIST 'THROW (FIRST THROW 'AND (SECOND THROW '-- 'YOUR 'POINT 'IS (+ (FIRST THROW (SECOND THROW ;;; end COND ;;; end LET

;;; ======================================== END OF PROGRAM CRAPS =