[plt-scheme] Unpredictable behaviour of plt Scheme 4.1.5

From: Andrew Reilly (andrew-scheme at areilly.bpc-users.org)
Date: Sun Apr 5 00:21:02 EDT 2009

On Fri, 3 Apr 2009 19:36:52 -0400
Eli Barzilay <eli at barzilay.org> wrote:

> On Apr  3, Marcin Karpinski wrote:
> > 
> > I know this is a pretty high-level explanation, but I can't for now
> > isolate the problem to few lines of code. Any clues?
> Perhaps you're using some kind of hash iteration, and side effects in
> the wrong order lead to bad results?

Just as a data-point: my project uses a hash-table based "set"
implementation, and one mode of operation is to collect a unique
set of things and then iterate over the resulting list.  It
completely surprised me that this produced essentially random
results, until I realized that the hash keys could very easily be
based on things like object addresses, which could be different
on each run.

For the moment I've decided to leave the non-determinism in
there, because it'll probably help me to find unexpected
order-dependency bugs, but ultimately I might need to add a
regularization step (like a sort), or change from a hash to a
tree or similar, so that users of the program aren't surprised by
getting different answers to the same question.



Posted on the users mailing list.