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: Sun, 27 Apr 2014 21:12:12 -0400 Message-ID: <8761lu8dg3.fsf@yeeloong.lan> References: <87mwf9hu1v.fsf@nebulosa.milkyway> <87ppk38tek.fsf@yeeloong.lan> <20140427191451.674c60b2@capac> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1398647676 13847 80.91.229.3 (28 Apr 2014 01:14:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 28 Apr 2014 01:14:36 +0000 (UTC) Cc: guile-user@gnu.org To: David Pirotte Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Apr 28 03:14:31 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 1Wea9N-0005yV-CL for guile-user@m.gmane.org; Mon, 28 Apr 2014 03:14:29 +0200 Original-Received: from localhost ([::1]:41121 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wea9M-0002en-Os for guile-user@m.gmane.org; Sun, 27 Apr 2014 21:14:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wea99-0002YW-J0 for guile-user@gnu.org; Sun, 27 Apr 2014 21:14:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wea94-00007t-Jz for guile-user@gnu.org; Sun, 27 Apr 2014 21:14:15 -0400 Original-Received: from world.peace.net ([96.39.62.75]:38754) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wea94-00006Y-Fg for guile-user@gnu.org; Sun, 27 Apr 2014 21:14:10 -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 1Wea8l-0008S4-L5; Sun, 27 Apr 2014 21:13:52 -0400 In-Reply-To: <20140427191451.674c60b2@capac> (David Pirotte's message of "Sun, 27 Apr 2014 19:14:51 -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:11241 Archived-At: David Pirotte writes: > 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? Read this: http://clhs.lisp.se/Body/07_ec.htm In particular: "In general, more than one class among C and its superclasses can define a slot with a given name. In such cases, only one slot with the given name is accessible in an instance of C, and the characteristics of that slot are a combination of the several slot specifiers, computed as follows: [...]" Here's a transcript of an SBCL session I tried on Debian: --8<---------------cut here---------------start------------->8--- This is SBCL 1.0.57.0.debian, an implementation of ANSI Common Lisp. More information about SBCL is available at . SBCL is free software, provided as is, with absolutely no warranty. It is mostly in the public domain; some portions are provided under BSD-style licenses. See the CREDITS and COPYING files in the distribution for more information. * (defclass foo () ((a :initform 'foo :reader foo-a) (b :initform 42))) # * (defclass bar (foo) ((a :initform 'bar))) # * (values (foo-a (make-instance 'foo)) (foo-a (make-instance 'bar))) FOO BAR --8<---------------cut here---------------end--------------->8--- Unknown_lamer on #guile tried the same thing with a different implementation of Common Lisp, and got the same answer. Mark