From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Pirotte Newsgroups: gmane.lisp.guile.user Subject: Re: #:getter procedure returns unexpected value in GOOPS Date: Sun, 27 Apr 2014 19:14:51 -0300 Message-ID: <20140427191451.674c60b2@capac> References: <87mwf9hu1v.fsf@nebulosa.milkyway> <87ppk38tek.fsf@yeeloong.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1398636941 18611 80.91.229.3 (27 Apr 2014 22:15:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 27 Apr 2014 22:15:41 +0000 (UTC) Cc: guile-user@gnu.org To: Mark H Weaver Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Apr 28 00:15:32 2014 Return-path: Envelope-to: guile-user@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 1WeXMC-0000By-Cn for guile-user@m.gmane.org; Mon, 28 Apr 2014 00:15:32 +0200 Original-Received: from localhost ([::1]:40718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WeXMB-0004JY-VR for guile-user@m.gmane.org; Sun, 27 Apr 2014 18:15:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WeXLq-0004Au-Qf for guile-user@gnu.org; Sun, 27 Apr 2014 18:15:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WeXLi-0001bc-Cv for guile-user@gnu.org; Sun, 27 Apr 2014 18:15:10 -0400 Original-Received: from maximusconfessor.all2all.org ([79.99.200.102]:52483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WeXLi-0001b6-6i for guile-user@gnu.org; Sun, 27 Apr 2014 18:15:02 -0400 Original-Received: from localhost (unknown [192.168.0.2]) by maximusconfessor.all2all.org (Postfix) with ESMTP id C7360A04C0DE; Mon, 28 Apr 2014 00:15:01 +0200 (CEST) Original-Received: from maximusconfessor.all2all.org ([192.168.0.1]) by localhost (maximusconfessor.all2all.org [192.168.0.2]) (amavisd-new, port 10024) with ESMTP id OQlxTEaZtczi; Sun, 27 Apr 2014 23:56:43 +0200 (CEST) Original-Received: from capac (unknown [189.60.2.251]) by maximusconfessor.all2all.org (Postfix) with ESMTPSA id 3C5A2A04C10D; Mon, 28 Apr 2014 00:14:54 +0200 (CEST) In-Reply-To: <87ppk38tek.fsf@yeeloong.lan> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 79.99.200.102 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:11240 Archived-At: Hi Mark, > > When using GOOPS, if a class has a second slot, the #:getter procedure > > of the first slot returns the value of the second slot when applied to > > an instance of a subclass. > > > > (use-modules (oop goops)) > > > > (define-class () > > (a #:init-form 'foo #:getter foo-a) > > (b #:init-form 42)) > > > > (define-class () > > (a #:init-form 'bar)) > > > > (foo-a (make )) => foo > > (foo-a (make )) => 42 > > > > I expected: > > > > (foo-a (make )) => bar > Indeed, CLOS behaves as you expected... Are you sure about that? I don't have a CLOS implementation 'at hand', and did not have the time to carefully (re)read the hyperspec doc (my knowledge of it is quite rusty now, it's been a very [very] long time since I studied it), but iirc, where the slot list of a subclass must be computed as being the union of ..., I am not sure it implies that a particular slot definition should result as the union of getters, setters, accessors and any of the previously defined slot option actually. Consider the following situation: (use-modules (oop goops)) (define-class () (a #:accessor blue #:allocation #:virtual #:slot-ref (lambda (obj) 'foo) #:slot-set! (lambda (obj val) (values)))) (define-class () (a #:accessor red #:init-value 'bar)) (class-slots ) (class-slots ) (define foo (make )) (define bar (make )) (blue bar) (red bar) (set! (blue bar) 'the-blue-bar) (set! (red bar) 'the-red-bar) (blue bar) (red bar) ... > I tried this example on both Guile 1.8 and Guile 1.6, and neither of > them behave as you expected. Instead they complain that there's no > applicable method for 'foo-a'. To me it is the right answer, the slot must be (re)defined, and not inherit any previously defined slot options, but of course I might be wrong. Cheers, David