[plt-scheme] swindle clos question

From: Larry White (ljw1001 at gmail.com)
Date: Fri Feb 4 14:42:37 EST 2005

I can't recall the term used in the clos world, but a variable that I
intended to be an inst variable seems to be acting like a class var
(oh yeah, class allocation, that's it).

I have the following hierarchy (extra fields removed):  

(defclass section ()
            (accumulators   :accessor accumulators   :initvalue 

(defclass group (section))

And the following methods

  (defmethod (add-accumulator (a accumulator)(sect section) key)
             (hash-table-put! (accumulators sect)  key a))

I create two groups and two accumulators (one for each) and assign them as so:

(define g1 (make-group "status" "Status"))
(define ac1 (make-count "status"))
(add-accumulator ac1 g1 'count-status)

(define g2 (make-group "type" "type"))
(define ac2 (make-count "type"))
(add-accumulator ac2 g2 'count-type)

What happens is that I seem to have a single hashtable in both groups.
 If I call the accessor (accumulators g1)  it has both entries and

(eq? (accumulators g1) (accumulators g2)) returns # t 

Can someone please clue me in? 


Posted on the users mailing list.