[plt-scheme] problems with structures in extensions

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Jul 23 09:27:34 EDT 2004

At Fri, 23 Jul 2004 13:47:50 +0400, Alex Ott wrote:
> I'm have a problem creating structure type in mzscheme extension. See
> attached file mzexts.c. 
> The instance constructor, filed accessors, etc. works fine:
> [...]
> But I can't create the subtype of this structure type:

The problem is that subtyping a struct with `define-struct' needs
compile-time information about the struct.

The simplest way to create the binding is to write it down directly:

 (define-syntax str
   (list-immutable #'struct:str #'make-str #'str?
                   (list-immutable #'str-fa #'str-fb #'str-fc)
                   (list-immutable #'set-str-fa! #'set-str-fb! #'set-str-fc!)
                   #t))

Currently, the interface for primitive modules doesn't support syntax
bindings, so there's no reasonable way to do this in C.

Matthew



Posted on the users mailing list.