Why does define-literal-set
complain about identifiers being unbound with respect to the enclosing module?
Well, is the identifier you provide unbound?
Yes… But I thought that the point of literals in syntax-parse
is that they’re supposed to be used for their literal symbolic name, so binding something to them seems counterintuitive, to me.
I’m trying to build a little DSL by using literal identifiers to tag parts of of the expression tree. As such, binding those identifiers to something wouldn’t be useful.
Actually, no. ~literal
recognizes identifiers by their binding, so they must be bound for it to work properly. If you want to use actual symbolic name, use ~datum
or #:datum-literals
#lang racket/base
(require syntax/parse)
(define-literal-set foo
#:datum-literals (a b c)
())
(syntax-parse #'b
#:literal-sets (foo)
[a 1]
[b 2]
[c 3])
FWIW, syntax-parse
encourages literals that are bound because experience has been that it works out better, even if the binding is a macro that complains about the identifier being used out of place.
My apologies, I misunderstood things. Thank-you for clarifying.