Hi, Kevin Ryde <[EMAIL PROTECTED]> 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