racket / redex

Other
93 stars 36 forks source link

define-term in pattern position #215

Open wilbowma opened 4 years ago

wilbowma commented 4 years ago

I usually think of any term being allowed in pattern position and simply acting as "unify with this".

I think of define-term as simply introducing a meta-variable that means literally the term being defined.

However, both of these mental models are broken when combined:

(require redex/reduction-semantics)
(define-language L)
(define-term T true)
> (redex-match? L true (term T))
#t
> (redex-match? L T (term true))
#f
> (define-judgment-form L
    #:mode (eval I O)
    [(eval true true)])
> (judgment-holds (eval T true))
#t
> (judgment-holds (eval T T))
#f

Is there a reason? Could this be supported?

rfindler commented 4 years ago

That would indeed be better, in this example (and many many similar ones), but the full ramifications of that seem quite subtle. It might be easy to do this but it might also be hard. I'll try to take a look.