Not sure if I’m being just being blind, but I can’t seem to run the examples for make-struct-info
in https://docs.racket-lang.org/reference/structinfo.html#%28def._%28%28lib._racket%2Fstruct-info..rkt%29._make-struct-info%29%29 When I run the following in the DrRacket definitions window #lang racket
(require racket/struct-info)
(define (new-pair? x) (displayln "new pair?") (pair? x))
(define (new-car x) (displayln "new car") (car x))
(define (new-cdr x) (displayln "new cdr") (cdr x))
(define-syntax new-list
(make-struct-info
(λ () (list #f
#'cons
#'new-pair?
(list #'new-cdr #'new-car)
(list #f #f)
#t))))
I get make-struct-info: undefined;
cannot reference an identifier before its definition
Does anyone know what’s going on?
@michaelmmacleod you probably want (require (for-syntax racket/struct-info))
That example should probably be changed to clarify that you need the for-syntax require
Ah, silly me — it works now, thanks!