sorawee
2021-8-11 08:41:52

Also, there’s a macro that does something like define-syntax-rule, but uses syntax-parse’s functionality: define-syntax-parse-rule.

(require syntax/parse/define) (define-syntax-parse-rule (dada-test place-term ({~literal true-when} read-holds-atomic-term ...)


greg
2021-8-11 13:15:12

There’s also the option of having your dada-test macro use Racket keywords for these, like #:true-when and #:false-when. As a matter of taste you might love or hate how they look, or you might not care either way. But they’re unambiguously keywords.


ben.knoble
2021-8-11 17:43:22

PS for #:literals from syntax-parse the keywords need bindings for-syntax; if you don’t care about that, use #:datum-literals instead.


shu--hung
2021-8-11 20:20:20

IIUC, those literals should not be required for-syntax. But they do need to be required normally and cannot be unbound. Their bindings are compared at phase 0 (which is the runtime one).


ben.knoble
2021-8-11 20:21:03

Ah, yes, perhaps it’s just define-syntax at phase–0—that seems closer to what I’m remembering


shu--hung
2021-8-11 20:24:11

+1. It also works for normal define but using define-syntax can generate error messages for out-of-context uses.


sorawee
2021-8-11 20:26:31

I really like ~literal over #:literals, but there is a difference: ~literal allows the id to be unbound. When the id is unbound, the id used in macro invocation must also be unbound, but with the same name


shu--hung
2021-8-11 22:09:34

So they are really merely compared by free-identifier=?!


sorawee
2021-8-11 23:43:16

apparently