Doesn't (struct ... #:guard guard-proc ...) not do what you want? See the doc on struct. Jos
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Eric Eide Sent: jueves, 29 de diciembre de 2016 2:55 To: Racket Users Subject: [racket-users] Racket-ese for Scheme `define-record-type' protocol? Hi! I'm translating a R6RS Scheme program to Racket, and I have a question about the best "Racket-ese" translation for Scheme's `define-record-type'. Consider the following R6RS definition: ----- (define-record-type racr-specification (fields (mutable specification-phase) rules-table (mutable start-symbol)) (opaque #t)(sealed #t) (protocol (lambda (new) (lambda () (new 1 (make-eq-hashtable 50) racr-nil))))) ----- What is the Racket translation of the protocol specification? Reading the online Racket docs, I don't see how to specify a different (and fresh per instance) value for every field within Racket's `struct` form. (#:auto and #:auto-value are not what I want; I need different values, and fresh values, for every created instance.) I guess I could "cheat" by defining the "expected" constructor myself: ----- (define (make-racr-specification) (racr-specification 1 (make-eq-hashtable 50) racr-nil)) ----- But this seems common enough that it would be built into `struct` in some way? Or maybe `struct` isn't what I want at all? Thanks --- Eric. (a Racket newbie) -- ------------------------------------------------------------------------------- Eric Eide <[email protected]> . University of Utah School of Computing http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

