[plt-scheme] getting the constructor from a struct-type
At Fri, 17 Feb 2006 08:53:39 -0500, Sam Tobin-Hochstadt wrote:
> On Thu, 2006-02-16 at 20:48 -0700, Matthew Flatt wrote:
> > At Thu, 16 Feb 2006 22:41:27 -0500, Sam Tobin-Hochstadt wrote:
> > > I'm curious about two things: first, might it be reasonable to extend
> > > the struct-type to contain the predicate and constructor, as it
> > > currently does for the accesssor etc?
> >
> > Code that already uses `struct-type-info' would break. And that code
> > (and yours) would break every time we want to add something new. For
> > that reason, I think it makes more sense to add functions.
>
> I wasn't suggesting that struct-type-info produce more values, since
> that has the obvious drawbacks you point out. I was thinking that
> struct-types could have the pointer to the constructor/predicate, so
> that they could be gotten w/ an accessor, rather than making new ones
> each time.
I'm reluctant to cache procedure values that might otherwise be garbage
collected. I'm not sure it was a good idea to cache the accessor and
mutator.
> > > Second, did the code I wrote,
> > > which calls, either scheme_make_struct_instance or
> > > scheme_make_struct_values, properly respect inspectors? Can you get
> > > around inspectors w/ the ffi?
> >
> > As far as I can tell, it ignores inspectors.
>
> What's the right way to check this from C/FFI code?
Call scheme_is_subinspector() on the struct-type's inspector and the
current inspector.
Matthew