>From the Guide:

-------
This code [...] has a subtle bug:

#lang racket
(let* ([fishes (list (fish 8 'red)
                     (fish 7 'blue))]
       [wb (make-weak-box (list-ref fishes 0))])
  (collect-garbage)
  (printf "still there? ~s\n" (weak-box-value wb)))

Specifically, it will show that the weak box is empty, but not because
fishes no longer holds onto the value, but because fishes itself is
not reachable anymore!
-------

The reason it's not reachable is because it is not actually referred
to in the source code, right?  It is theoretically still reachable in
the scope of the 'collect-garbage' call **if you actually put a
mention of it in the code** but in this particular case it's not
reachable because there is no such reference.

In the next section they do exactly that and state that fishes is now
reachable again, so I want to confirm that I understand properly what
caused the change.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to