From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.bugs Subject: bug#20423: goops - inheritance of slot options Date: Thu, 23 Jun 2016 22:23:53 +0200 Message-ID: <87inwzlkme.fsf@pobox.com> References: <20150424230538.67db3eaa@capac> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1466713532 31889 80.91.229.3 (23 Jun 2016 20:25:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 23 Jun 2016 20:25:32 +0000 (UTC) Cc: 20423@debbugs.gnu.org To: David Pirotte Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Thu Jun 23 22:25:20 2016 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bGBBf-0005lE-Aw for guile-bugs@m.gmane.org; Thu, 23 Jun 2016 22:25:19 +0200 Original-Received: from localhost ([::1]:39192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGBBe-0007Og-EU for guile-bugs@m.gmane.org; Thu, 23 Jun 2016 16:25:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGBBS-0007Jd-7E for bug-guile@gnu.org; Thu, 23 Jun 2016 16:25:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bGBBO-0005OT-1K for bug-guile@gnu.org; Thu, 23 Jun 2016 16:25:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40688) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGBBN-0005OK-RE for bug-guile@gnu.org; Thu, 23 Jun 2016 16:25:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bGBBN-0005of-Ms for bug-guile@gnu.org; Thu, 23 Jun 2016 16:25:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andy Wingo Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 23 Jun 2016 20:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20423 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 20423-submit@debbugs.gnu.org id=B20423.146671344922280 (code B ref 20423); Thu, 23 Jun 2016 20:25:01 +0000 Original-Received: (at 20423) by debbugs.gnu.org; 23 Jun 2016 20:24:09 +0000 Original-Received: from localhost ([127.0.0.1]:53025 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGBAX-0005nI-5F for submit@debbugs.gnu.org; Thu, 23 Jun 2016 16:24:09 -0400 Original-Received: from pb-sasl2.pobox.com ([64.147.108.67]:63080 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGBAV-0005n9-Lr for 20423@debbugs.gnu.org; Thu, 23 Jun 2016 16:24:08 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id 6349C246CD; Thu, 23 Jun 2016 16:24:05 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=flcVKktTwk+Ze12pM/OgANTyOVg=; b=U4+v+5 SiLPtFXKUuk7md1A4ZenkNdj4q97yYUdCqY2cnUTTGu97OfFZRPIZSYat0j5P15F hJi+cID7sduCAZWw1deAlpG+6BeTjM1lg57NPE3R8jUa/kr++2UmCyqOEBXh7gQl TjYZXB2kH6T9bYQcL0J2BL+7c839mbhghZMOw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=iq/mUW+gKRpxWjGaDyay3ZPntMXX4CTt 7/T0WTQZtq3bvUQG2+lLp2Wfpgr5zjFWtVjIybyy1UD0PGWaXix38e6ABumET837 KHMFT5fyRsrMPQP/1EBM9TBJnzagRMMsCRV9KRJcFWZRVNJ4B9b+t0V0V801ksBQ 9Huj11EFeGQ= Original-Received: from pb-sasl2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id 5D06F246CC; Thu, 23 Jun 2016 16:24:05 -0400 (EDT) Original-Received: from clucks (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl2.pobox.com (Postfix) with ESMTPSA id 0FBD0246CB; Thu, 23 Jun 2016 16:24:03 -0400 (EDT) In-Reply-To: <20150424230538.67db3eaa@capac> (David Pirotte's message of "Fri, 24 Apr 2015 23:05:38 -0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-Pobox-Relay-ID: 6DE92CEE-3980-11E6-9604-28A6F1301B6D-02397024!pb-sasl2.pobox.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:8185 Archived-At: 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 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 () > ((name :accessor name :init-keyword :name :init-form "") > (age :accessor age :init-keyword :age :init-form -1))) > > (define-class () > ((subject :accessor subject :init-keyword :subject :init-form ""))) > > (define-class () > ((subject :init-form "Mathematics"))) > > david@capac:~/alto/projects/stklos 15 $ stklos > * STklos version 1.10 > * Copyright (C) 1999-2011 Erick Gallesio - Universite de Nice > * * [Linux-3.16.0-4-amd64-x86_64/pthread/readline/utf8] > stklos> (load "subclass-slot-redefinition.scm") > stklos> (define p2 (make :name 'john :age 34)) > ;; p2 > stklos> (describe p2) > #[ 28a2420] is an an instance of class . > 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 () > (name #:accessor name #:init-keyword #:name #:init-form "") > (age #:accessor age #:init-keyword #:age #:init-form -1)) > > (define-class () > (subject #:accessor subject #:init-keyword #:subject #:init-form "")) > > (define-class () > (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 #:name 'john #:age 34)) > scheme@(guile-user)> ,use (oop goops describe) scheme@(guile-user)> (describe p2) > #< 1432300> is an instance of class > Slots are: > name = john > age = 34 > subject = "Mathematics" > scheme@(guile-user)> (subject p2) > ERROR: In procedure scm-error: > ERROR: No applicable method for #< subject (1)> in call (subject > #< 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.)