[Reality] Is collect() broken?

Jp Calderone exarkun at divmod.com
Fri Jun 4 13:27:19 MDT 2004


   This is based on radix's example.

   Consider a battery shed.  It has an open window and a closed window. 
  Inside are heaps and heaps of batteries.  An actor outside the shed 
attempts to take one of the batteries.

   collect() will reach the actor's location from the actor, and then do 
both of the following two things in some order:

     reach the open window from the actor's location, reach the interior 
of the shed from the open window, reach a battery from the shed, yield a 
battery to the caller (because things can be taken through open windows).

     reach the closed window from the actor's location, reach the 
interior of the shed from the closed window, reach a battery from the 
shed, yield a refusal around the battery (because things can't be taken 
through open windows).

   Or will it!  In fact, it will not.  Whichever runs first will cause 
the shed to be added to the seen dictionary, which will in turn cause 
the subsequent portion of the traversal, upon reaching the shed, to skip 
it.  If the open window is traversed first, the battery will be 
takeable.  If the closed window is traversed first, the battery will not 
be takeable.

   How can we solve this?  Off the top of my head, and with no filters 
for putrification factor:

   * yield an "unsee" callable with each implementor.  Calling this 
would allow an implementor to be yielded again.

   * Don't put implementors in the seen dict, or put use a path segment 
leading up to the implementor in the seen dict with it, so that an 
object reached via multiple paths can be yielded multiple times.  Fix 
code using collect() to be aware of this possibility.

   * ... ?

   Jp




More information about the Reality mailing list