[racket-dev] Set Equality with Cyclic Structure is not as Expected

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Tue May 8 09:39:15 EDT 2012

This may be a consequence of updating mutable state inside a set
datastructure.  I haven't tried yet, but non-cyclic uses of mutable boxes
inside sets may have similar results.

Carl Eastlund

On Tue, May 8, 2012 at 9:25 AM, Matthias Felleisen <matthias at ccs.neu.edu>wrote:

>
> Looks like a bug. Why don't you file a bug report?
>
>
> On May 7, 2012, at 6:33 PM, Daniel King wrote:
>
> > Hi,
> >
> > The following code snippet is a bit confusing to me. Sets with cyclic
> structure
> > are not equal? even though they meet my intuitive definition of equal.
> I'm
> > curious exactly where my intuition goes wrong.
> >
> > I imagine the reason why Racket can conclude that the lists are equal is
> because
> > the ordering of the list provides a necessary level of disambiguation.
> With a
> > set, Racket cannot be certain which element should match between the two
> > data, and this means potentially following cycles forever? I'm not
> entirely
> > clear on my reasoning, but I think this must be related to the root
> cause.
> >
> > Note in the following snippet the let* forms differ only in the data
> constructor
> > used: `set' in the first form and `list' in the second form.
> >
> > racket@> (let* ((a-box (box #f))
> >                (b-box (box #f))
> >                (a (set 1 a-box))
> >                (b (set 1 b-box)))
> >           (set-box! a-box a)
> >           (set-box! b-box b)
> >           (displayln a)
> >           (displayln b)
> >           (equal? a b))
> > #0=#<set: 1 #&#0#>
> > #0=#<set: 1 #&#0#>
> > #f
> > racket@>  (let* ((a-box (box #f))
> >                 (b-box (box #f))
> >                 (a (list 1 a-box))
> >                 (b (list 1 b-box)))
> >            (set-box! a-box a)
> >            (set-box! b-box b)
> >            (displayln a)
> >            (displayln b)
> >            (equal? a b))
> > #0=(1 #&#0#)
> > #0=(1 #&#0#)
> > #t
> >
> > P.S.
> >
> > For future reference, is this more of users@ material or dev@ material?
> >
> > --
> > Dan King
> > College of Computer and Information Science
> > Northeastern University
> > _________________________
> >  Racket Developers list:
> >  http://lists.racket-lang.org/dev
>
>
> _________________________
>  Racket Developers list:
>  http://lists.racket-lang.org/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20120508/f26ddf35/attachment.html>

Posted on the dev mailing list.