guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GOOPS Bug with slotless child classes?


From: Clinton Ebadi
Subject: GOOPS Bug with slotless child classes?
Date: Wed, 05 Jan 2005 18:06:18 -0500

Code:
(use-modules (oop goops))

(define-class <parent> ()
  (atts #:init-keyword #:atts
        #:allocation #:instance)) ; Make 100% sure it is instance

;; Note: no slots of its own
(define-class <child> (<parent>))

(define parent-object-1 (make <parent> #:atts '(parent-1 atts)))
(define parent-object-2 (make <parent> #:atts '(parent-2 atts)))

(define child-object-1 (make <child> #:atts '(child-2 atts)))
(define child-object-2 (make <child> #:atts '(child-2 atts)))

(define (write-atts obj)
  (write obj)
  (newline)
  (write (slot-ref obj 'atts))
  (newline))

(write-atts parent-object-1)
(write-atts parent-object-2)
(write-atts child-object-1)
(write-atts child-object-2)

Output:
guile> (load "goops-bug.scm")
#<<parent> 8089e40>
(parent-1 atts)
#<<parent> 8089e30>
(parent-2 atts)
#<<child> 8089e20>
(child-2 atts)
#<<child> 8089e10>
(child-2 atts)

Are instance slots of a parent class supposed to be shared across all
instances of a child? If this is intentional (as in C++, as far as I can
remember [my C++ class inheritance model knowledge is getting fuzzy from
disuse]), is there a way to make each instance of the subclass have it's
own copy of the parent class without abusing the MOP? The GOOPS manual
doesn't have any info on this.

I'm using slotless less classes in Guile-Web
<http://unknownlamer.org/code/guile-web.html> and this causes the tag
attributes to be shared amongst all tags of the same type (empty,
non-empty, or tag-list). The reason for using the different kinds of
tags is so that I can easily overload display/write to make the code
cleaner.

As soon as I work around this Guile-Web 0.4.3 will be released (which
will work with Guile 1.7 among other things).

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]