University of Virginia, Department of Computer Science
CS200: Computer Science, Spring 2003

Notes: Monday 17 March 2003
Schedule

Notes
(define (make-number n)
  (lambda (message)
    (cond
     ((eq? message 'value) (lambda (self) n))
     ((eq? message 'add) (lambda (self other)
			   (+ (ask self 'value) (ask other 'value))))))))

(define (ask object message . args) (apply (object message) object args))
Inheritance is using the definition of one class to make another class.
(define (make-fraction numer denom)
  (let ((super (make-number #f)))
    (lambda (message)
      (cond
       ((eq? message 'value) (lambda (self) (/ numer denom)))
       ((eq? message 'get-denominator) (lambda (self) denom))
       ((eq? message 'get-numerator) (lambda (self) numer))
       (else (super message))))))
The class fraction inherits from number.
fraction is a subclass of number.
The superclass of fraction is number.

Which of the traced applications are from fraction and which are from number?
> (ask half 'add half)
|(ask # add #)
| (eq? add value)
| #f
| (eq? add get-denominator)
| #f
| (eq? add get-numerator)
| #f
| (eq? add value)
| #f
| (eq? add add)
| #t
| (ask # value)
| |(eq? value value)
| |#t
| 1/2
| (ask # value)
| |(eq? value value)
| |#t
| 1/2
|1
1
TerraServer
1 Terabyte = 240 bytes (about 1 Trillion bytes)

http://terraserver.microsoft.com/ — 3.3 Terabytes of aerial images covering entire United States
     UVa Image

CS 200


CS 200: Computer Science
Department of Computer Science
University of Virginia

Circle Fractal by Ramsey Arnaoot and Qi Wang

cs200-staff@cs.virginia.edu
Using these Materials