From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: goops proposal: proper struct classes Date: Thu, 05 May 2011 20:25:20 +0200 Message-ID: References: <87fwot14wl.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1304619939 21128 80.91.229.12 (5 May 2011 18:25:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 5 May 2011 18:25:39 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu May 05 20:25:33 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QI3Ey-0007yu-2p for guile-devel@m.gmane.org; Thu, 05 May 2011 20:25:32 +0200 Original-Received: from localhost ([::1]:46600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QI3Ex-00056Y-Kq for guile-devel@m.gmane.org; Thu, 05 May 2011 14:25:31 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:58318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QI3Eu-00056T-8P for guile-devel@gnu.org; Thu, 05 May 2011 14:25:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QI3Es-0003w7-Vr for guile-devel@gnu.org; Thu, 05 May 2011 14:25:28 -0400 Original-Received: from a-pb-sasl-sd.pobox.com ([64.74.157.62]:56228 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QI3Es-0003w0-T9; Thu, 05 May 2011 14:25:26 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 84A9B4052; Thu, 5 May 2011 14:27:30 -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:content-transfer-encoding; s=sasl; bh=bDBjAt1V06pr oxJBzPxisTDPww0=; b=fRyA5ZqLpzjmlCLPAqEpM/4DMsWSOQjDImEXV4Vp5lbj iPCOOu7iEKi4xPgJdry2AjOWrPHMSlFpRTqssZPaIVuVIrhbfJxpsbNFbA6+s32G hkxODo+WsSWSrlR5UEVe6XLh5jw0MlzlM7H1GWEtp84yNvOw8b6alYciazG+4og= 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:content-transfer-encoding; q=dns; s=sasl; b=jdNaHL WkN/+To9IQsJjKyjjTg9Ihc6NWBVg8cCCLP+4MACKSk/ebhVAFShhoYEXCj3/jvz BctYztf8zslpZR+z5tyRMBzO1RBD/GTAxIGgijXS3ylKKXZBft2iVsxMDSKQ1wXY uhUxj/FOH+UlH/EQHb1XY8GMR/JkiJCGpRJ+U= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 70AA94051; Thu, 5 May 2011 14:27:29 -0400 (EDT) Original-Received: from unquote.localdomain (unknown [90.164.198.39]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id B27184045; Thu, 5 May 2011 14:27:27 -0400 (EDT) In-Reply-To: <87fwot14wl.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Thu, 05 May 2011 18:35:54 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-Pobox-Relay-ID: 559B034A-7745-11E0-B7F6-90BEB0B5FC3A-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 64.74.157.62 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:12434 Archived-At: Hi :) On Thu 05 May 2011 18:35, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Andy Wingo writes: > >> If you know GOOPS, then you know that we have classes, rooted at >> . And indeed shows up a lot in documentation and in >> code. But that's not how it is in CLOS: our corresponds to >> their `standard-class'. They have a superclass, called `class', which >> is the real root, and from which e.g. structure classes are derived. >> >> We need to do this. Currently, class-of on a struct/record data type >> gives a useless class that can't instantiate instances, doesn't know its >> slots, and does not reflect the vtable hierarchy. > > Here=E2=80=99s an illustration: > > scheme@(guile-user)> (use-modules (oop goops) (srfi srfi-9)) > scheme@(guile-user)> (define-record-type (make-foo x) foo? (x foo-x= )) > scheme@(guile-user)> (make-foo 2) > $3 =3D #< x: 2> > scheme@(guile-user)> (class-of $3) > $4 =3D #< <> 148a4b0> Here it probably should have a name, even now; probably a bug, that srfi-9 should call set-struct-vtable-name! on the rtd. > scheme@(guile-user)> (class-slots $4) > $5 =3D () > scheme@(guile-user)> (class-of $4) > $6 =3D #< 8e7a50> Here's the problem, for me:=20 scheme@(guile-user)> (define-record-type (make-foo x) foo? (x foo= -x)) scheme@(guile-user)> (make-foo 10) $1 =3D #< x: 10> scheme@(guile-user)> (struct-vtable $1) $2 =3D # scheme@(guile-user)> (struct-vtable $2) $3 =3D # scheme@(guile-user)> (struct-vtable $3) $4 =3D # See? The struct's vtable is actually an instance of another vtable -- of another class -- and that metaclass is a vtable-vtable (because $3 and $4 are equal). So class-of $2 should yield the class-of $3, which is actually some other bug: scheme@(guile-user)> (class-of $2) $5 =3D #< <> 368e870> scheme@(guile-user)> (class-of $3) $6 =3D #< <> 368e870> >> So we need a , interposed between and , >> which will be the real root of our class meta-object hierarchy. > > Why? > > Couldn=E2=80=99t =E2=80=98scm_i_define_class_for_vtable=E2=80=99 build a = full-blown class, > populating its CPL, its =E2=80=98slots=E2=80=99 slot, etc.? Yes, it could. I didn't mention that. I think that such a duplicate hierarchy is unnecessary, because we can define methods for some of the class protocol (class-name at least!). Vtables *are* classes, on a fundamental level. Bare vtables are not as nice as , but they do describe instances. SCM_CLASS_OF() is SCM_STRUCT_VTABLE(). WDYT? Am I off the deep end again? :) Andy --=20 http://wingolog.org/