This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
GOOPS and class linearization
- To: mdj at nada dot kth dot se
- Subject: GOOPS and class linearization
- From: Michael Livshin <mlivshin at bigfoot dot com>
- Date: 09 Feb 2000 19:06:41 +0200
- Cc: guile at sourceware dot cygnus dot com
- Organization: who? me?
currently, `compute-std-cpl' works consistently with the classic CLOS
class linearization:
[ taken from goops.scm, verified to be true: ]
;;; (define-class food ())
;;; (define-class fruit (food))
;;; (define-class spice (food))
;;; (define-class apple (fruit))
;;; (define-class cinnamon (spice))
;;; (define-class pie (apple cinnamon))
;;;
;;; => cpl (pie) = pie apple fruit cinnamon spice food object top
I was somewhat uneasy with this algorithm for some time, and now I
know why, having stumbled upon some papers and having thought
alittle. (never does harm, that ;)
the problem with this algorithm is that it makes general mixin
programming unpredictable. consider:
(define-class <a> () (x #:init-value 0 #:accessor x))
(define-class <son-of-a> (<a>))
(define-class <mixin> () (x #:init-value 5 #:accessor x))
(define-class <bastard-son-of-a> (<son-of-a> <mixin>))
(x (make <bastard-son-of-a>))
==> 0 ; oops!
the people who designed Dylan remedied the problem by defining the cpl
of a class as a merge of the local precedence order with the
precedence order of the direct superclasses, so that the example at
the beginning of this message would instead produce:
=> cpl (pie) = pie apple cinnamon fruit spice food object top
I suggest that this problem be remedied while the GOOPS specification
is still subject to change.
for detailed description see:
http://www.webcom.com/haahr/dylan/linearization-oopsla96.html
--mike
--
All ITS machines now have hardware for a new machine instruction --
CIZ
Clear If Zero.
Please update your programs.