[racket] can racket have a regexp-equal?

From: ozzloy (ozzloy at gmail.com)
Date: Sat Nov 26 18:05:01 EST 2011

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
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20111126/3b4f2955/attachment.html>

Posted on the users mailing list.