[racket] struct and when the accessors are bound

From: Alexander D. Knauth (alexander at knauth.org)
Date: Wed Jul 16 10:44:24 EDT 2014

If I have a program like this:
#lang racket/base
(define-values (prop:p p? p-ref)
  (make-struct-type-property 'p))
(struct foo (a) #:transparent
  #:property prop:p foo-a)
It gives me this error:
. foo-a: undefined;
 cannot reference an identifier before its definition

Is there a reason why I can’t do this?

And is there any way to get around this other than wrapping foo-a in a lambda?

I know that this works:
#lang racket/base
(define-values (prop:p p? p-ref)
  (make-struct-type-property 'p))
(struct foo (a) #:transparent
  #:property prop:p (λ (x) (foo-a x)))

And I know that it’s not that bad, but is there any other way around it?



Posted on the users mailing list.