Am 03.10.2006 um 00:47 schrieb kirby urner: >> This metaphor may be good for references, but not for Python. You >> are >> left with the intuition that you can look at the mug and enumerate >> the >> handles. Maybe a an object is a living thing with lasers shining >> on it >> (referring to it), that may shrivel up and die if it gets no light. >> >> -- Scott David Daniels > > Good caveat. > > I could keep the "mug with many handles" metaphor, but then explain > only the Garbage Collector really knows when it's time for a mug to > meet its maker (i.e. return its piece of Memory to that great Heap in > the Sky).
A mug to me sounds way too similar to "bit bucket". That's how low- level languages (like C++) present variables. Also, it's hard to imagine how to describe, say, a linked list as a chain of mugs. I like to explain objects as balloons, with labeled hooks on its surface as variables. A balloon can have more than one leash, but each hook holds exactly one leash (still looking for a metaphor that naturally has this constraint). Garbage collection then simply occurs when all leashes of an object are removed from the hooks - a whole tangle of objects might float up. The idea extends even to weak references, which is a leash not tied but loosely attached to a hook :) - Bert - _______________________________________________ Edu-sig mailing list [email protected] http://mail.python.org/mailman/listinfo/edu-sig
