unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: David Pirotte <david@altosw.be>
To: 20423@debbugs.gnu.org
Subject: bug#20423: goops - inheritance of slot options
Date: Fri, 24 Apr 2015 23:05:38 -0300	[thread overview]
Message-ID: <20150424230538.67db3eaa@capac> (raw)

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

Hello,

	GNU Guile 2.0.11.114-649ec
	goops - inheritance of slot options
	severity - serious

The current goops implementation breaks the [clos] protocol [*] for inheritance of
slot options.  This is a serious bug.

Below, [A] what stklos does, [B] what goops does, [*] a summary of what the clos
protocol says wrt  inheritance of slot options.

Cheers,
David


[A]	Here is what stklos does:

	stklos/subclass-slot-redefinition.scm

--8<---------------cut here---------------start------------->8---
(define-class <person> ()
  ((name :accessor name :init-keyword :name :init-form "")
   (age :accessor age :init-keyword :age :init-form -1)))

(define-class <teacher> (<person>)
  ((subject :accessor subject :init-keyword :subject :init-form "")))

(define-class <maths-teacher> (<teacher>)
  ((subject :init-form "Mathematics")))
--8<---------------cut here---------------end-------------->8---

david@capac:~/alto/projects/stklos 15 $ stklos
*   STklos version 1.10
 *  Copyright (C) 1999-2011 Erick Gallesio - Universite de Nice <eg@unice.fr>
* * [Linux-3.16.0-4-amd64-x86_64/pthread/readline/utf8]
stklos> (load "subclass-slot-redefinition.scm")
stklos> (define p2 (make <maths-teacher> :name 'john :age 34))
;; p2
stklos> (describe p2)
#[<maths-teacher> 28a2420] is an an instance of class <maths-teacher>.
Slots are: 
     age = 34
     name = john
     subject = "Mathematics"
stklos> (subject p2)
"Mathematics"
stklos> 


[B]	Here is what goops does:

	goops/subclass-slot-redefinition.scm

--8<---------------cut here---------------start------------->8---
(use-modules (oop goops))

(define-class <person> ()
  (name #:accessor name #:init-keyword #:name #:init-form "")
  (age #:accessor age #:init-keyword #:age #:init-form -1))

(define-class <teacher> (<person>)
  (subject #:accessor subject #:init-keyword #:subject #:init-form ""))

(define-class <maths-teacher> (<teacher>)
  (subject #:init-form "Mathematics"))
--8<---------------cut here---------------end-------------->8---

david@capac:~/alto/projects/guile-tests/goops 51 $ guile
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)> (load "subclass-slot-redefinition.scm")
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /usr/alto/projects/guile-tests/goops/subclass-slot-redefinition.scm
;;;
compiled /home/david/.cache/guile/ccache/2.0-LE-8-2.0/usr/alto/projects/guile-tests/goops/subclass-slot-redefinition.scm.go
scheme@(guile-user)> (define p2 (make <maths-teacher> #:name 'john #:age 34))
scheme@(guile-user)> ,use (oop goops describe) scheme@(guile-user)> (describe p2)
#<<maths-teacher> 1432300> is an instance of class <maths-teacher>
Slots are: 
     name = john
     age = 34
     subject = "Mathematics"
scheme@(guile-user)> (subject p2)
ERROR: In procedure scm-error:
ERROR: No applicable method for #<<accessor> subject (1)> in call (subject
#<<maths-teacher> 1432300>)

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> 


[*] A summary of what the clos protocol says:

	[ this is a copy/paste from a clos tutorial, also pointed by
	[ the Stklos reference manual:

	[	http://www.aiai.ed.ac.uk/~jeff/clos-guide.html#slots

	When there are superclasses, a subclass can specify a slot that has already
	been specified for a superclass. When this happens, the information in slot
	options has to be combined. For the slot options listed above, either the
	option in the subclass overrides the one in the superclass or there is a
	union:

	   :ACCESSOR  -  union
	   :INITARG   -  union
	   :INITFORM  -  overrides

	This is what you should expect. The subclass can change the default initial
	value by overriding the :initform, and can add to the initargs and accessors.

	However, the union for :accessor is just a consequence of how generic
	functions work. If they can apply to instances of a class C, they can also
	apply to instances of subclasses of C. (Accessor functions are generic.)

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

             reply	other threads:[~2015-04-25  2:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-25  2:05 David Pirotte [this message]
2016-06-23 20:23 ` bug#20423: goops - inheritance of slot options Andy Wingo
2016-06-23 23:08   ` David Pirotte
2016-06-24  1:06     ` dsmich
2016-06-24  5:04     ` Andy Wingo
2016-07-12 20:02       ` David Pirotte
2016-06-24  5:12     ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150424230538.67db3eaa@capac \
    --to=david@altosw.be \
    --cc=20423@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).