[racket] redex: default matching behavior of patterns

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue May 1 19:57:38 EDT 2012

Sorry-- this was already unchangable 5 years ago, nevermind today.

Robby

On Tue, May 1, 2012 at 6:56 PM, Jon Rafkind <rafkind at cs.utah.edu> wrote:
> Just in case it was unclear I was hoping people would explicitly adorn pattern variables if they want to match the same term.
>
> (simple integer_1 integer_1)
>
> But if (simple integer integer) to match the same term twice is a heavily used form then so be it..
>
> On 05/01/2012 05:52 PM, Robby Findler wrote:
>> This is heavily relied on.
>>
>> Robby
>>
>> On Tue, May 1, 2012 at 6:45 PM, Jon Rafkind <rafkind at cs.utah.edu> wrote:
>>> The default matching behavior of patterns in redex will try to match duplicate pattern variables to the same term. Thus
>>>
>>> #lang racket
>>>
>>> (require redex)
>>>
>>> (define-language Z [x integer])
>>> (define-metafunction Z
>>>  simple : integer integer -> integer
>>>  [(simple integer integer) 1])
>>>
>>> (term (simple 1 2))
>>>> simple: no clauses matched for (simple 1 2)
>>> Won't match because the pattern (simple integer integer) will match the first `integer' to 1, and wants to the second reference to `integer' to the same thing. To get it to work I need to adorn the pattern variables with _1 and _2 to make them unique.
>>>
>>> (define-language Z [x integer])
>>> (define-metafunction Z
>>>  simple : integer integer -> integer
>>>  [(simple integer_1 integer_2) 1])
>>>
>>> I would prefer (if possible) if the default behavior treated unadorned pattern variables as fresh so that I don't have to remember to attach a suffix. I guess this might break existing programs but I can't imagine anyone really relies on this behavior (unadorned variables matching duplicate terms).
>>> ____________________
>>>  Racket Users list:
>>>  http://lists.racket-lang.org/users
>


Posted on the users mailing list.