[plt-scheme] getting the constructor from a struct-type

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Feb 16 21:08:31 EST 2006

I finally got a chance to look into this.

As far as I can remember, `struct-type-info' was meant to provide
information for inspecting/adjusting an existing structure, and that's
why the predicate and constructor were left out. In particular,
`struct-type-info' was added at the same time that `struct-ref' and
`struct-set!' were removed.

I'll add `struct-type-make-constructor' and
`struct-type-make-predicate' in the next version. (The "make" in the
name indicates that a new constructor/predicate will be created each


At Wed, 15 Feb 2006 15:04:40 -0500, Sam Tobin-Hochstadt wrote:
> On Tue, 2006-02-14 at 17:52 -0500, Sam Tobin-Hochstadt wrote:
> > I would like to perform functional update on arbitrary structures
> > (modulo inspectors) and thus I'd like to be able to construct instances
> > of a structure given the structure-type.  However, struct-type-info
> > doesn't return the constructor (or the selector).  Before I write an ffi
> > extension to call scheme_make_struct_values, I wondered if anyone had
> > run across this problem before, and if there were any better solutions.
> Attached is some simple code which uses the FFI (thanks Eli!) to expose
> this functionality.  I'm not sure, however, if it respects inspectors
> properly.  It exposes both scheme_make_struct_instance and an "accessor"
> for getting the predicate and constructor from a struct type. [1]
> If anyone has a better solution for this, I'd love to hear it.
> sam th
> [1] It's not accessor since it creates new such functions via
> scheme_make_struct_values.
> ------------------------------------------------------------------------------
> [text/x-scheme "make-struct-instance.scm"] [save & open]
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.