From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.user Subject: Re: #:getter procedure returns unexpected value in GOOPS Date: Sat, 26 Apr 2014 21:15:15 -0400 Message-ID: <87ppk38tek.fsf@yeeloong.lan> References: <87mwf9hu1v.fsf@nebulosa.milkyway> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1398561443 30263 80.91.229.3 (27 Apr 2014 01:17:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 27 Apr 2014 01:17:23 +0000 (UTC) Cc: guile-user@gnu.org To: "Diogo F. S. Ramos" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Apr 27 03:17:16 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 1WeDiV-0001io-V5 for guile-user@m.gmane.org; Sun, 27 Apr 2014 03:17:16 +0200 Original-Received: from localhost ([::1]:37672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WeDiV-0003ab-Cv for guile-user@m.gmane.org; Sat, 26 Apr 2014 21:17:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WeDiI-0003aV-Ss for guile-user@gnu.org; Sat, 26 Apr 2014 21:17:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WeDiD-0002Pu-H0 for guile-user@gnu.org; Sat, 26 Apr 2014 21:17:02 -0400 Original-Received: from world.peace.net ([96.39.62.75]:37712) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WeDiD-0002Pp-CG for guile-user@gnu.org; Sat, 26 Apr 2014 21:16:57 -0400 Original-Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=yeeloong.lan) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1WeDi5-0005jq-Oo; Sat, 26 Apr 2014 21:16:49 -0400 In-Reply-To: <87mwf9hu1v.fsf@nebulosa.milkyway> (Diogo F. S. Ramos's message of "Fri, 25 Apr 2014 20:24:12 -0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 96.39.62.75 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:11230 Archived-At: "Diogo F. S. Ramos" writes: > 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, and GOOPS should probably behave the same way. However, it appears that overriding the attributes of slots in subclasses has not worked this way in a long time, if ever. 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'. Can you please send a bug report to bug-guile@gnu.org? For now, I suggest adding an initialize method for , like this: --8<---------------cut here---------------start------------->8--- (use-modules (oop goops)) (define-class () (a #:init-form 'foo #:getter foo-a) (b #:init-form 42)) (define-class ()) (define-method (initialize (obj ) args) (slot-set! obj 'a 'bar) (next-method)) (foo-a (make )) => foo (foo-a (make )) => bar --8<---------------cut here---------------end--------------->8--- Regards, Mark