Sun Mar 14 14:49:41 CET 2010
The example from fig1+2 in .
;;; Fig 1: Creating classes and objects
;; Real number objects are described by a pair of integers (m . e)
;; where the value x is determined by x = m * 10^e
(define real-class (make-top-class))
;; Integer objects are described by a single integer; to instantiate
;; as a real number, use an exponent of 1.
(lambda (x) (make-object real-class
(cons x 0)))))
;;; Fig 2: Creating methods
(declare-method (num->string n))
(method real-class num->string
(let ((data (view real-class n))
(mant (car data))
(exp (cdr data)))
(format "~sE~s" mant exp))))
(method int-class num->string
(let ((snum (view int-class n)))
;; Methods are functions that take the object as an argument. The
;; `view' form returns the internal representation of an object.
I don't understand: why does int-class call (make-object real-class
...) while it still has access to the integer?
I don't get the paper. I find no point to hook on. Maybe some code
and interaction would help?