unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#19770: goops - setter inheritance bug - serious
@ 2015-02-04 15:43 David Pirotte
  2016-06-23  9:11 ` Andy Wingo
  0 siblings, 1 reply; 2+ messages in thread
From: David Pirotte @ 2015-02-04 15:43 UTC (permalink / raw)
  To: 19770

[-- Attachment #1: Type: text/plain, Size: 2256 bytes --]

Hello,

	GNU Guile 2.0.11.114-649ec
	goops - setter inheritance bug
	severity - serious

setters are beeing redefined, not inhereted:  this is a serious bug.

Cheers,
David


--8<---------------cut here---------------start------------->8---
(define-module (a)
  #:use-module (oop goops)
  #:export (<a>
	    !width))


(define-class <a> ()
  (width #:accessor !width #:init-keyword #:width #:init-value 0))

(define-method ((setter !width) (self <a>) width)
  ;; here comes complex code, computing earth orbit, captain's age...
  (pk "this is <a> !width setter method, hello!")
  (slot-set! self 'width width))
--8<---------------cut here---------------start------------->8---

--8<---------------cut here---------------start------------->8---
(define-module (b)
  #:use-module (oop goops)
  #:use-module (a)
  #:export (<b>)

  #:re-export (!width))


(define-class <b> (<a>))
--8<---------------cut here---------------start------------->8---

GNU Guile 2.0.11.114-649ec
Copyright (C) 1995-2014 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> 
scheme@(guile-user)> ,use (oop goops)
scheme@(guile-user)> ,use (b)
;;; note: source file ./b.scm
;;;       newer than compiled /home/david/.cache/guile/ccache/2.0-LE-8-2.0/usr/alto/projects/guile-tests/goops/setter-inheritance-bug/b.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling ./b.scm
;;; note: source file ./a.scm
;;;       newer than compiled /home/david/.cache/guile/ccache/2.0-LE-8-2.0/usr/alto/projects/guile-tests/goops/setter-inheritance-bug/a.scm.go
;;; compiling ./a.scm
;;; compiled /home/david/.cache/guile/ccache/2.0-LE-8-2.0/usr/alto/projects/guile-tests/goops/setter-inheritance-bug/a.scm.go
;;; compiled /home/david/.cache/guile/ccache/2.0-LE-8-2.0/usr/alto/projects/guile-tests/goops/setter-inheritance-bug/b.scm.go
scheme@(guile-user)> (set! (!width (make <b>)) 20)
$2 = 20
scheme@(guile-user)> 
			   

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* bug#19770: goops - setter inheritance bug - serious
  2015-02-04 15:43 bug#19770: goops - setter inheritance bug - serious David Pirotte
@ 2016-06-23  9:11 ` Andy Wingo
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Wingo @ 2016-06-23  9:11 UTC (permalink / raw)
  To: David Pirotte; +Cc: 19770-done

Hi David,

Sorry for the long delay.  I think this is not a bug.  The reason is
that you defined !width as an #:accessor.  That means that each concrete
class which has a `width' slot will have its own accessor method
installed on it.  You overrode the method for <a> instances but not for
any other concrete class; e.g. <b> will have its own method.

If you want to run methods in the setter, you need to not define !width
as an accessor and instead rely on your define-method to create !width
as a normal generic.  I.e. remove #:accessor !width from (define-class
a).

Andy

On Wed 04 Feb 2015 16:43, David Pirotte <david@altosw.be> writes:

> Hello,
>
> 	GNU Guile 2.0.11.114-649ec
> 	goops - setter inheritance bug
> 	severity - serious
>
> setters are beeing redefined, not inhereted:  this is a serious bug.
>
> Cheers,
> David
>
>
> (define-module (a)
>   #:use-module (oop goops)
>   #:export (<a>
> 	    !width))
>
>
> (define-class <a> ()
>   (width #:accessor !width #:init-keyword #:width #:init-value 0))
>
> (define-method ((setter !width) (self <a>) width)
>   ;; here comes complex code, computing earth orbit, captain's age...
>   (pk "this is <a> !width setter method, hello!")
>   (slot-set! self 'width width))
>
> (define-module (b)
>   #:use-module (oop goops)
>   #:use-module (a)
>   #:export (<b>)
>
>   #:re-export (!width))
>
>
> (define-class <b> (<a>))
>
> GNU Guile 2.0.11.114-649ec
> Copyright (C) 1995-2014 Free Software Foundation, Inc.
>
> Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
> This program is free software, and you are welcome to redistribute it
> under certain conditions; type `,show c' for details.
>
> Enter `,help' for help.
> scheme@(guile-user)> 
> scheme@(guile-user)> ,use (oop goops)
> scheme@(guile-user)> ,use (b)
> ;;; note: source file ./b.scm
> ;;;       newer than compiled /home/david/.cache/guile/ccache/2.0-LE-8-2.0/usr/alto/projects/guile-tests/goops/setter-inheritance-bug/b.scm.go
> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
> ;;;       or pass the --no-auto-compile argument to disable.
> ;;; compiling ./b.scm
> ;;; note: source file ./a.scm
> ;;;       newer than compiled /home/david/.cache/guile/ccache/2.0-LE-8-2.0/usr/alto/projects/guile-tests/goops/setter-inheritance-bug/a.scm.go
> ;;; compiling ./a.scm
> ;;; compiled /home/david/.cache/guile/ccache/2.0-LE-8-2.0/usr/alto/projects/guile-tests/goops/setter-inheritance-bug/a.scm.go
> ;;; compiled /home/david/.cache/guile/ccache/2.0-LE-8-2.0/usr/alto/projects/guile-tests/goops/setter-inheritance-bug/b.scm.go
> scheme@(guile-user)> (set! (!width (make <b>)) 20)
> $2 = 20
> scheme@(guile-user)> 
> 			   





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

end of thread, other threads:[~2016-06-23  9:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-04 15:43 bug#19770: goops - setter inheritance bug - serious David Pirotte
2016-06-23  9:11 ` Andy Wingo

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).