Allegro CL Certification Program

Slides:



Advertisements
Similar presentations
Unit 8 Combination Circuits
Advertisements

Generics "It is easy to study the rules of overloading and of templates without noticing that together they are one of the keys to elegant and efficient.
Object-Oriented Programming In Lisp. Lisp vs. Scheme 1.Lisp has much more built-in functions and special forms, the Scheme language definition takes 45.
CLOS To start off with, CLOS (pronounced “kloss” or “see- loss”) is very different from other object oriented programming languages –Multiple inheritance.
Alok Mehta - Programming in Lisp - Lecture Programming in Lisp Lecture 6 - Structure; Case Study: Blocks World.
Common Lisp! John Paxton Montana State University Summer 2003.
Using Classes Lisp also supports the Object-Oriented paradigm. The process of defining classes in Lisp is similar to how you you define structures. The.
Structures Structures in LISP are analogous to that in C. To create a structure, use the following syntax: (defstruct Name Slot1 Slot2 Slot3) An example.
Alok Mehta - Programming in Lisp - Data Abstraction and Mapping Programming in Lisp Common Lisp Object System (CLOS)
F RANZ I NC. An In-Depth Look at Simple Streams By Duane Rettig October, 2002.
Allegro CL Certification Program Lisp Programming Series Level I Session Top Ten Things to Know.
Def D OC An extensible, dynamic document creation system By Rahul Jain
Error Handling Common Lisp has the throw/catch statements so that you can simulate exception handling as seen in languages like Java But CL goes far beyond.
1 CLOS: Common Lisp Object System Basic principles of CLOS Classes, Instances and Slots Inheritance Generic functions Methods Multi-methods Comparison.
ITEC 380 Organization of programming languages Lecture 5 – Functional Programming.
Allegro CL Certification Program Lisp Programming Series Level I Session Basic Lisp Development in the IDE.
Introduction to LISP. Lisp Extensible: It lets you define new operators yourself Lisp programs are expressed as lisp data structures –You can write programs.
Review of objects  overview overview. Class of objects  Attributes/ methods.
USCISIUSCISI Miscellaneous Issues Frame Functions Saving and Restoring CLOS Classes Mix and Match Inferencing.
Intelligence Musical and Otherwise.  Huh? Huh? Webster’s definition  Intelligence:  The ability to reason.
Structures “The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by.
1 CSE 2337 Chapter 7 Organizing Data. 2 Overview Import unstructured data Concatenation Parse Create Excel Lists.
As a general rule you should be using multiple languages these days (except for Java)
Class Diagram Associations Class Diagrams, Class Stereotypes, Class Associations Dr. Neal CIS 480.
Object Oriented Programming Some Interesting Genes.
Dept. of Computer & Information Sciences
Microsoft Office Access 2010 Lab 1
Prof. Fateman CS164 Lecture 35
Digital Aerospace and Defense Build, Service, and Fly Better
Working with Data Blocks and Frames
Teaching a machine a simple taxonomy
OBJECT ORIENTED CONCEPT
KeePass Password Safe Dan Koller Jesse Cowan.
Looking at our “Getting Started” application
Modern Programming Languages Lecture 20 Fakhar Lodhi
Ruby Classes, Modules & Mixins
EE2E1. JAVA Programming Revision Lecture.
Java Primer 1: Types, Classes and Operators
Moxie Manager: Basics Instructors Upload and Manage Content in MyPortal (Jenzabar LMS) July 2016 Sign in and Start at Academics tab.
(defmacro (delay x) (list 'lambda () x))
CSE (c) S. Tanimoto, 2002 AI Techniques
CLOS CSC 358/
CIS 764 Database Systems Engineering
Satisfying Open/Closed Principle
Contract Compliance: Search
Continuous Slot Well Screens.
PRG 420 NERD Education for Service-- prg420nerd.com.
EBSCO Discovery Service
SmartMove Taxi Dispatching System
Advanced Java Programming
Allegro CL Certification Program
J.E. Spragg Mitthögskolan 1997
Liquid Common Lisp On Suns.
Chapter 11: Classes, Instances, and Message-Handlers
More Object-Oriented Programming
| Website for students | VTU NOTES
Allegro CL Certification Program
CSE (c) S. Tanimoto, 2004 AI Techniques
Allegro CL Certification Program
Defining Macros in Lisp
Notes from Week 5 CSE 115 Spring 2006 February 13, 15 & 17, 2006.
PowerPoint Now, I will explain about power point.
Database – Mobile Phones
Common Lisp II.
Mental Strategies.
Allegro CL Certification Program
Defining Macros in Scheme
Databases WOW!! A database is a collection of related data.
LISP primitives on sequences
Presentation transcript:

Allegro CL Certification Program Lisp Programming Series Level 2 Session 2.2.1 Top Ten Things to do in CLOS

1. Define a Class (defclass position () ((x :initform 0 :initarg :x :accessor x-position) (y :initform 0 :initarg :y :accessor y-position)))

2. Make an Instance (setq s1 (make-instance 'position)) (x-position s1) (setf (x-position s1) 5) 5 (setq s2 (make-instance 'position :x 10 :y 10)) (x-position s2) 10

3. Define a Subclass (defclass aircraft (position) ((speed :initform 0 :initarg :speed :accessor speed) (flightno :initform "" :initarg :flightno :accessor flightno))) (setq m1 (make-instance ‘aircraft :x 5 :y 5 :speed 2 :flightno 1024))

4. Use Methods (defmethod name ((a aircraft)) (concatenate 'string "flight " (princ-to-string (flightno a)))) (defmethod draw ((a aircraft) stream) (draw-text stream (name a) (x-position a) (y-position a)))

5. Use Method Combination (defclass aircraft-with-icon (aircraft) ()) (defmethod draw :AFTER ((a aircraft-with-icon) stream) "After drawing the name, draw the icon" (draw-icon stream *plane-icon* (x-position a) (y-position a)))

6. Initialize Instances (defvar *all-aircraft* nil) (defmethod initialize-instance :after ((a aircraft) &allow-other-keys) (push a *all-aircraft*))

7. Use Slot-Value (defmethod set-position ((p position) x y) (setf (slot-value p 'x) x) (setf (slot-value p 'y) y) t) (defmethod get-position ((p position)) (values (slot-value p 'x) (slot-value p 'y)))

About Slot-Value You can always access a slot using slot-value The general rule is to prefer accessor methods (e.g. x-position and y-position) over raw slot-value. Exceptions: When the accessor function has a lot of :after, :before, or :around methods, slot-value is faster The accessor function may have :AFTER methods that you want to avoid in some cases

8. Use SETF methods (defmethod (setf x-position) :after (newvalue (a aircraft)) (redraw-display *screen*)) ;; This causes a redisplay when the ;; position changes (setf (x-position myaircraft) 16)

9. Use Multiple Dispatch (defmethod save ((p position) (stream file-stream)) . . . ) (defmethod save ((a aircraft) (stream file-stream)) (defmethod save ((p position) (stream database)) (defmethod save ((a aircraft) (stream database)) ;; The applicable method(s) depends on ;; multiple arguments.

10. Use Multiple Inheritance (defclass boeing-747 (passengers-mixin commercial-mixin aircraft) ()) ;; The class is (in most ways) the union ;; of the structure and behavior of the ;; components.