PLT Scheme Extracting field ids from structures

Posted by Steve Knight on Stack Overflow See other posts from Stack Overflow or by Steve Knight
Published on 2010-05-30T22:28:47Z Indexed on 2010/05/30 22:32 UTC
Read the original article Hit count: 396

Filed under:

I want to see if I can map PLT Scheme structure fields to columns in a DB.

I've figured out how to extract accessor functions from structures in PLT scheme using the fourth return value of:

(struct-type-info)

However the returned procedure indexes into the struct using an integer. Is there some way that I can find out what the field names were at point of definition? Looking at the documentation it seems like this information is "forgotten" after the structure is defined and exists only via the generated-accessor functions: (<id>-<field-id> s).

So I can think of two possible solutions:

  1. Search the namespace symbols for ones that start with my struct name (yuk);
  2. Define a custom define-struct macro that captures the ordered sequence of field-names inside some hash that is keyed by struct name (eek).

© Stack Overflow or respective owner

Related posts about plt-scheme