From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludovic.courtes@laas.fr (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: make-vtable Date: Tue, 13 Feb 2007 09:13:17 +0100 Organization: LAAS-CNRS Message-ID: <87r6suv5k2.fsf@laas.fr> References: <877iunt6yl.fsf@zip.com.au> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1171354422 27538 80.91.229.12 (13 Feb 2007 08:13:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 13 Feb 2007 08:13:42 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Feb 13 09:13:35 2007 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HGsn8-0003VC-PY for guile-devel@m.gmane.org; Tue, 13 Feb 2007 09:13:35 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HGsn8-0003wT-2Z for guile-devel@m.gmane.org; Tue, 13 Feb 2007 03:13:34 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HGsn0-0003tM-Ge for guile-devel@gnu.org; Tue, 13 Feb 2007 03:13:26 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HGsmv-0003oW-Hq for guile-devel@gnu.org; Tue, 13 Feb 2007 03:13:25 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HGsmv-0003oE-6Z for guile-devel@gnu.org; Tue, 13 Feb 2007 03:13:21 -0500 Original-Received: from laas.laas.fr ([140.93.0.15]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.52) id 1HGsmu-0004jh-1U for guile-devel@gnu.org; Tue, 13 Feb 2007 03:13:20 -0500 Original-Received: by laas.laas.fr (8.13.8/8.13.8) with SMTP id l1D8DG3D011508; Tue, 13 Feb 2007 09:13:17 +0100 (MET) X-URL: http://www.laas.fr/~lcourtes/ X-Revolutionary-Date: 25 =?iso-8859-1?Q?Pluvi=F4se?= an 215 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEB1F5364 X-PGP-Key: http://www.laas.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 821D 815D 902A 7EAB 5CEE D120 7FBA 3D4F EB1F 5364 X-OS: powerpc-unknown-linux-gnu Mail-Followup-To: guile-devel@gnu.org In-Reply-To: <877iunt6yl.fsf@zip.com.au> (Kevin Ryde's message of "Tue, 13 Feb 2007 08:13:38 +1100") User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) X-Spam-Score: 0.307 () MAILTO_TO_SPAM_ADDR X-Scanned-By: MIMEDefang at CNRS-LAAS on 140.93.0.15 X-detected-kernel: Solaris 10 (beta) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:6520 Archived-At: Hi, Kevin Ryde writes: > I made a bit of a start trying to improve the structures section of > the manual, I always found it pretty hard to follow. One big > stumbling block for me was vtables, but I now see if you want to make > a struct you have to make a vtable vtable, and from that a vtable, and > only then your struct. Seems hard work for casual users, if you're > not (at first) interested in that second level of "type of type". My understanding (which might be inaccurate) is that there is in fact no such three-level indirection: in classic reflective OO terms, `make-vtable-vtable' returns a "class" object which `make-struct' can then use to return regular (i.e., non-class) objects. In particular, this example (from `structs.test') works: (let* ((vtable (make-vtable-vtable "pr" 0)) (s1 (make-struct vtable 0 "hello")) (s2 (make-struct vtable 0 "hello"))) ;; S1 and S2 are both "regular" one-field structs. (equal? s1 s2)) So I think it's even more confusing than it seems. ;-) I'd say that `make-vtable-vtable' is inappropriately named and should really be `make-vtable'. Does that make sense? (Not to mention that the primary use of the term "vtable" is for _method_ pointers in C++, which definitely has nothing to do with this.) > How about something like this to just make a vtable from fields and > optional printer func, > > (define (make-vtable fields . print) > (apply make-struct (make-vtable-vtable "" 0) 0 > (make-struct-layout fields) > print)) IIUC, `(define make-vtable make-vtable-vtable)' should suffice. Thanks, Ludovic. _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel