unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* GOOPS Bug with slotless child classes?
@ 2005-01-05 23:06 Clinton Ebadi
  2005-01-05 23:28 ` Stephen Compall
  2005-01-05 23:45 ` Clinton Ebadi
  0 siblings, 2 replies; 3+ messages in thread
From: Clinton Ebadi @ 2005-01-05 23:06 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 1752 bytes --]

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 #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: GOOPS Bug with slotless child classes?
  2005-01-05 23:06 GOOPS Bug with slotless child classes? Clinton Ebadi
@ 2005-01-05 23:28 ` Stephen Compall
  2005-01-05 23:45 ` Clinton Ebadi
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Compall @ 2005-01-05 23:28 UTC (permalink / raw)
  Cc: guile-user


[-- Attachment #1.1: Type: text/plain, Size: 685 bytes --]

On Wed, 2005-01-05 at 18:06 -0500, Clinton Ebadi wrote:
> (define child-object-1 (make <child> #:atts '(child-2 atts)))
> (define child-object-2 (make <child> #:atts '(child-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?

I changed the first quoted line to say

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

and got this output:

#<<parent> 40341760>
(parent-1 atts)
#<<parent> 4033dcc0>
(parent-2 atts)
#<<child> 4033d430>
(child-1 atts)
#<<child> 40337c80>
(child-2 atts)

-- 
Stephen Compall

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: GOOPS Bug with slotless child classes?
  2005-01-05 23:06 GOOPS Bug with slotless child classes? Clinton Ebadi
  2005-01-05 23:28 ` Stephen Compall
@ 2005-01-05 23:45 ` Clinton Ebadi
  1 sibling, 0 replies; 3+ messages in thread
From: Clinton Ebadi @ 2005-01-05 23:45 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 143 bytes --]

Ignore me. I was being stupid.

The bug in guile-web is with me not deep copying a list when I should
be. Oops.

Sometimes I'm retarded.

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-01-05 23:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-05 23:06 GOOPS Bug with slotless child classes? Clinton Ebadi
2005-01-05 23:28 ` Stephen Compall
2005-01-05 23:45 ` Clinton Ebadi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).