From: ludovic.courtes@laas.fr (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: Re: make-vtable
Date: Thu, 15 Feb 2007 09:45:27 +0100 [thread overview]
Message-ID: <8764a3kdw8.fsf@laas.fr> (raw)
In-Reply-To: <87tzxopinw.fsf@zip.com.au> (Kevin Ryde's message of "Thu, 15 Feb 2007 07:51:15 +1100")
Hi,
Kevin Ryde <user42@zip.com.au> writes:
> ludovic.courtes@laas.fr (Ludovic Courtès) writes:
>>
>> I'm not sure the indirection in `scm_init_stacks ()' is needed since it
>> uses STACK_LAYOUT for both VTABLE and SCM_STACK_TYPE,
>
> Not sure what you mean there.
We have:
VTABLE -> SCM_STACK_TYPE -> stack objects
where `x -> y' means "`y' is an instance of `x'". When creating stack
objects with (roughly) `(make-struct stack-type)', VTABLE is _not_
consulted at all. The layout of stack objects is determined only by
that specified in SCM_STACK_TYPE. Thus, VTABLE is redundant.
All this would be clearer if we had a `struct-vtable' type such that
`(make-struct struct-vtable)' would yield a new vtable (just like `(make
<class>)' yields a new GOOPS class). Like `<class>', `struct-vtable'
would terminate the "reflective tower" (i.e., its vtable is itself).
Actually, such a `struct-vtable' stealthily appears in
`make-vtable-vtable', under the name of REQUIRED_VTABLE_FIELDS: We could
really have a `struct-vtable' whose layout is REQUIRED_VTABLE_FIELDS and
then `make(-vtable)+' could be simply implemented in terms of
`make-struct' (just like `make-class' uses `make').
I guess I should try implementing this theory one of these days. ;-)
> At any rate, below is where I'm up to so far with trying to make the
> docs a bit easier. It includes my proposed make-vtable. Could be
> possible to leave that out, but perhaps those like me who managed to
> never understand structs can see if it makes the understanding easier
> :-).
Thanks for working on this!
> A "structure" is a first class data type which holds Scheme values or C
> words in slots numbered 0 upwards. A "vtable" represents a structure
> type, giving read/write permissions on slots, whether they're Scheme
> values or uninterpreted words, and giving an optional print function
> for the structure (for use by `write' etc).
Perhaps a word saying the struct fields are laid out in a contiguous
memory area, which makes interaction with C much easier (using C arrays
or some such).
> Vtable Vtables
> ..............
>
> As noted above, vtables are structures and such a structure is itself
> described by a vtable. Such a "vtable of a vtable" can be created with
> `make-vtable-vtable' below and used to build sets of related vtables,
> possibly with extra application fields.
>
> This second level of vtable can be a little confusing. An example,
> and indeed a typical use, is Guile's own record system (*note
> Records::). Currently record types are implemented as vtables, and
> those vtables have an extra slot holding the list of field names for
> that type (as passed to `make-record-type').
While the rest looks good, I remain skeptical about this part. And a
manual that claims to be confusing does not inspire confidence. ;-)
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-15 8:45 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 ` make-vtable Ludovic Courtès
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 ` Ludovic Courtès [this message]
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=8764a3kdw8.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).