kellysmith12.21
2020-8-17 14:25:03

Why does define-literal-set complain about identifiers being unbound with respect to the enclosing module?


sorawee
2020-8-17 14:29:23

Well, is the identifier you provide unbound?


kellysmith12.21
2020-8-17 14:41:54

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.


kellysmith12.21
2020-8-17 14:47:35

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.


sorawee
2020-8-17 15:06:23

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


sorawee
2020-8-17 15:08:25

#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])


mflatt
2020-8-17 16:28:43

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.


kellysmith12.21
2020-8-17 17:44:58

My apologies, I misunderstood things. Thank-you for clarifying.