From: ludovic.courtes@laas.fr (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: Re: make-vtable
Date: Tue, 13 Feb 2007 09:13:17 +0100 [thread overview]
Message-ID: <87r6suv5k2.fsf@laas.fr> (raw)
In-Reply-To: <877iunt6yl.fsf@zip.com.au> (Kevin Ryde's message of "Tue, 13 Feb 2007 08:13:38 +1100")
Hi,
Kevin Ryde <user42@zip.com.au> 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
next prev parent reply other threads:[~2007-02-13 8:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-12 21:13 make-vtable Kevin Ryde
2007-02-13 8:13 ` Ludovic Courtès [this message]
2007-02-13 21:26 ` make-vtable Kevin Ryde
2007-02-14 8:01 ` make-vtable Ludovic Courtès
2007-02-14 20:51 ` make-vtable Kevin Ryde
2007-02-15 8:45 ` make-vtable Ludovic Courtès
2007-02-16 0:07 ` make-vtable Kevin Ryde
2007-02-16 8:12 ` make-vtable Ludovic Courtès
2007-02-18 18:10 ` make-vtable Neil Jerram
2007-02-18 20:05 ` make-vtable Ludovic Courtès
2007-02-18 23:56 ` make-vtable Neil Jerram
2007-02-19 0:14 ` make-vtable Kevin Ryde
2007-02-19 0:39 ` make-vtable Neil Jerram
2007-02-19 8:39 ` make-vtable Ludovic Courtès
2007-03-06 0:27 ` make-vtable Kevin Ryde
2007-03-06 8:32 ` make-vtable Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r6suv5k2.fsf@laas.fr \
--to=ludovic.courtes@laas.fr \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).