[racket] free-id-table-ref odd behavior

From: J. Ian Johnson (ianj at ccs.neu.edu)
Date: Thu Nov 22 11:26:25 EST 2012

I'm making my first macro that communicates across uses via compile-time mutation. Somehow my entries are not being looked up correctly.

Say I have a compile-time table:

(define-for-syntax optional (make-free-id-table))

That in the first invocation is populated with #'state \mapsto (list foo bar)
The second invocation needs info about #'state (and is given as part of the macro input. I try to look up the list with (get-op #'parameter-bound-to-state)

(define-for-syntax (get-op id)
  (free-id-table-for-each optional
                          (λ (id* v) (printf "Found? ~a ~a~%" #'id* (free-identifier=? id id*))))
  (free-id-table-ref optional id
                     (λ () (raise-syntax-error #f "Unregistered struct" id))))

This prints "Found? state #t" and then errors on the ref.
What's going on?

-Ian


Posted on the users mailing list.