unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: David Pirotte <david@altosw.be>
Cc: 20423@debbugs.gnu.org
Subject: bug#20423: goops - inheritance of slot options
Date: Thu, 23 Jun 2016 22:23:53 +0200	[thread overview]
Message-ID: <87inwzlkme.fsf@pobox.com> (raw)
In-Reply-To: <20150424230538.67db3eaa@capac> (David Pirotte's message of "Fri,  24 Apr 2015 23:05:38 -0300")

Hi,

For what it's worth this is a part of GOOPS's design AFAIU: all slot
definitions are unique.  Two slots named S declared on classes A and B
are distinct, even if A is a superclass of B.

I don't know if we can change this.  I guess maybe.  There would have to
be a design though.  I guess fleshing out the `compute-slots' protocol
from http://www.alu.org/mop/concepts.html#class-finalization-protocol
would be the thing.

I believe that technically you can already provide your own
`compute-slots' implementation, but you are probably missing some
definitions that would help you do so in a compatible manner.  Check it
out for yourself and give it a go, no need to wait on Guile people :)

Andy

On Sat 25 Apr 2015 04:05, David Pirotte <david@altosw.be> writes:

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





  reply	other threads:[~2016-06-23 20:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-25  2:05 bug#20423: goops - inheritance of slot options David Pirotte
2016-06-23 20:23 ` Andy Wingo [this message]
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=87inwzlkme.fsf@pobox.com \
    --to=wingo@pobox.com \
    --cc=20423@debbugs.gnu.org \
    --cc=david@altosw.be \
    /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).