[plt-scheme] Determining number of fields in a struct at expansion time

From: Richard Cobbe (cobbe at ccs.neu.edu)
Date: Tue Nov 6 22:43:23 EST 2007

On Tue, Nov 06, 2007 at 08:20:02PM -0700, Matthew Flatt wrote:
> At Tue, 6 Nov 2007 22:09:53 -0500, Richard Cobbe wrote:
> > Specifically, the fourth element of the list obtained for the struct is
> >
> >     an immutable list of identifiers bound to the field accessors of the
> >     structure type, optionally with #f as the list's last element. A #f as
> >     the last element indicates that the structure type may have additional
> >     fields, otherwise the list is a reliable indicator of the number of
> >     fields in the structure type. Furthermore, the accessors are listed in
> >     reverse order for the corresponding constructor arguments. (The reverse
> >     order enables sharing in the lists for a subtype and its base type.)
> >
> > (MzScheme manual, section 12.6.4.)
> >
> > Under what conditions will the list of identifiers end with #f?
> In v4, it can happen with
>   (define-struct s (a b c)
>                  #:super struct:t)
> as opposed to
>   (define-struct (s t) (a b c))

Ok, I see.  Does that mean that if I stick to the second form of
define-struct, I'll never have to worry about the trailing #f?

FWIW, I'm currently working in 371.3, but I'll probably end up moving to v4
before I'm finished using this code.



Posted on the users mailing list.