[racket] can racket have a regexp-equal?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sat Nov 26 18:06:07 EST 2011

Oh, sorry-- it was changed before you sent your message. :)

Robby

On Sat, Nov 26, 2011 at 5:05 PM, ozzloy <ozzloy at gmail.com> wrote:
> wow, that was really fast.  thanks!
>
> On Sat, Nov 26, 2011 at 09:37, Robby Findler <robby at eecs.northwestern.edu>
> wrote:
>>
>> This has been changed in the current pre-release version, available
>> from git and via a nightly build:
>>
>>  http://pre.racket-lang.org/installers/
>>
>> Robby
>>
>> On Fri, Nov 25, 2011 at 3:22 PM, ozzloy <ozzloy at gmail.com> wrote:
>> > i was writing a unit test which had something analogous to the
>> > following:
>> > (check-equal? #rx"a" #rx"a")  => raises exn:test:check
>> > so i checked and sure enough:
>> > (equal? #rx"a" #rx"a) => #f
>> > which led me to look for a regexp-equal? so i could do (check
>> > regexp-equal?
>> > #rx"a" #rx"a")
>> > that doesn't exist, so i wrote one:
>> > (define (regexp-equal? a b)
>> >   (and (and (regexp? a)
>> >             (regexp? b))
>> >        (or (and (pregexp? a)
>> >                 (pregexp? b))
>> >            (and (not (pregexp? a))
>> >                 (not (pregexp? b))))
>> >        (equal? (object-name a)
>> >                (object-name b))))
>> > why not just have (equal? #rx"a" #rx"a") => #t ?
>> > anticipated objection: "what should equal? mean for two regexps?"
>> > it should mean that the patterns are identical, totally ignoring that
>> > two
>> > non-identical patterns might match exactly the same set, like #rx"(a|b)"
>> > and
>> > #rx"(b|a)".
>> > i see in the docs that there is an internal regexp value.  if those are
>> > what
>> > i think they are, i propose equal? just compares those for regexes.
>> >
>> > _________________________________________________
>> >  For list-related administrative tasks:
>> >  http://lists.racket-lang.org/listinfo/users
>> >
>
>



Posted on the users mailing list.