[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make-vtable

From: Kevin Ryde
Subject: Re: make-vtable
Date: Fri, 16 Feb 2007 11:07:34 +1100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

address@hidden (Ludovic Courtès) writes:
> 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.

Well, except for the creation (and continued existance) of

> 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).

Yes, as long as you don't want any extra fields in the vtable (which
is true for scm_stack_type).  I thought of that for my make-vtable

    (define make-vtable
      (let ((vtable-vtable #f))
        (lambda (fields tail-size . print)
          (or vtable-vtable
              (set! vtable-vtable (make-vtable-vtable "" 0)))
          (apply make-struct vtable-vtable tail-size
                 (make-struct-layout fields)

Then wondered if it was worth bothering with.  I guess if it's used by
stacks.c too then it should share.  (The name `struct-vtable' is taken
by a func, but some other global name ...)

> 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 think the problem is if you want extra fields in the vtables.  Maybe
a third level of table descriptor could do that (as opposed to
self-vtabling roots).  Though for now I'm only really looking at
describing it, not changing it.

> 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).

Yep.  I guess documenting SCM_STRUCT_DATA or whatever it is to get at
them will be necessary too, if we're really pretending it's useful in

> While the rest looks good, I remain skeptical about this part.  And a
> manual that claims to be confusing does not inspire confidence.  ;-)

It's ok to admit it's potentially confusing, if that's then followed
by good explanation :-).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]