[plt-scheme] Attaching compile-time information to structure types

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Wed Feb 13 12:48:32 EST 2008

Hi all,

I have another macrological question,related to but separate from my  
last one about my SQL wrapper.

I have a macro, define-persistent-struct, that defines a struct that  
can be serialized to a database. define-persistent-struct basically  
works like define-struct, except it creates a few more variables. For  

     (define-persistent-struct person ([name type:string] [age  

would define all the things that define-struct would defined:

     person, struct:person, make-person, person?, person-age, person- 
name and so on...

plus some metadata that gets attached via a property:

    entity:person, attr:person-age, attr:person-name ...

I'd like to attach some extra compile-time information to person so I  
can retrieve the bindings for entity:person and attr:whatever in macros.

I hacked something up by subtyping struct-info from scheme/private/ 
struct-info.ss and adding extra fields to it. This works for the most  
part, but it is obviously not the recommended approach as  
struct:struct-info isn't provided from struct-info.ss. I've also had  
problems using scheme/match in certain cases.

Can anyone point me in the right direction?

Thanks in advance,

-- Dave

Posted on the users mailing list.