[racket] build-struct-generation

From: Shriram Krishnamurthi (sk at cs.brown.edu)
Date: Sat Sep 3 08:06:11 EDT 2011

build-struct-generation is a really useful utility, but I don't
understand how to use it.  Specifically, see

Welcome to DrRacket, version 5.1.3 [3m].
Language: racket; memory limit: 128 MB.
> (require syntax/struct)
> (build-struct-generation #'p (list #'x #'y) #f #f)
'(let-values (((struct: make- ? acc mut)
                '.#<syntax:5:29 p>
                ()      ;; <---
                ())))   ;; <---
    (make-struct-field-accessor acc 0 '.#<syntax:5:39 x>)
    (make-struct-field-mutator mut 0 '.#<syntax:5:39 x>)
    (make-struct-field-accessor acc 1 '.#<syntax:5:43 y>)
    (make-struct-field-mutator mut 1 '.#<syntax:5:43 y>)))

Note the two empty lists in the output [()'s with the default printer;
in constructor mode they come out as empty's].  They correspond to

  props : (listof (cons/c struct-type-property? any/c)) = null
  immutables : (listof exact-nonnegative-integer?) = null

However, these are in code that it meant to subsequently be
evaluated.  When used, for instance, in a macro, I get

  #%app: missing procedure expression; probably originally (), which
  is an illegal empty application in: (#%app)

Is it possible to get a simple example of how to use this?


Posted on the users mailing list.