[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:09:53 EST 2007

I'm working on a macro that processes (sub)structure definitions.  In order
to handle substructures correctly, I need to know the number of fields that
each substructure inherits from its parent.  I know that using
`syntax-local-value' on the structure's name will get me the information,
but the docs do mention something that makes me worried.

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?  Very
rudimentary exploration with the macro stepper suggests that this doesn't
happen in most cases, and so I can safely ignore this possibility (since
this macro is intended for my use only and not for general distribution).

Or am I overlooking something?

Thanks,

Richard


Posted on the users mailing list.