On Dolphin 6, I evaluate this in a workspace:
| a b | a := Time now. 12345 timesRepeat: [Time now] . b := Time now. a oneWayBecome: b. a = b -> true But, according to the method-documentation of #oneWayBecome: " .... anObject replaces all uses of the receiver, and the receiver's identity and contents are lost. " So you would expect the 'a' in my expression to become nil, right? Somehow it seems to 'lose' nothing in the above example. Is there a discrepancy between the documentation and behavior? If so, which one should be fixed? Thanks for putting in the #oneWayBecome:. I'd just like to be sure about its intended, stable, semantics. -Panu Viljamaa |
Panu,
> On Dolphin 6, I evaluate this in a workspace: > > | a b | > a := Time now. > 12345 timesRepeat: [Time now] . > b := Time now. > a oneWayBecome: b. > a = b > > -> true > > But, according to the method-documentation of #oneWayBecome: > > " .... anObject replaces all uses of the receiver, and the > receiver's identity and contents are lost. > " > > So you would expect the 'a' in my expression to become > nil, right? Somehow it seems to 'lose' nothing in the > above example. Is there a discrepancy between the > documentation and behavior? If so, which one should > be fixed? Hmmm... I don't understand what you're saying. For e.g. | a b | a := Time now. "12:45am" 12345 timesRepeat: [Time now]. "Is this just a delay?" b := Time now. "12:46am" a oneWayBecome: b. a = b "true" a == b "true" a "12:46am" b "12:46am" So the original contenst of a (12:45am) were thrown away and GC'd and replaced by the contents of b (12:46am). Now a and b point to the same object. Perhaps the comment should say "and the receiver's original identiity and contents are lost". Does that help? -- Best regards, Andy Bower Dolphin Support www.object-arts.com |
Andy Bower wrote:
> ... > So the original contenst of a (12:45am) were thrown away and GC'd and > replaced by the contents of b (12:46am). Now a and b point to the same > object. > > Perhaps the comment should say "and the receiver's original identiity > and contents are lost". > > Does that help? Yes, I now understand the source of my confusion. When I first saw this method I was quite excited that Dolphin has more than one type of #become:. So I immediately thought "How can I create a test that shows this behavior?". Your example shows that the two variables now point to the same object, but it doesn't really show that one object has "lost its identity". In fact there's no way we can show it has "lost its identity", because - it no longer exists! And, it would be quite hard to devise a test that shows it doesn't exist too. Your explanation in terms of GC makes its much clearer, I think. When the comment says "... receiver's identity and contents are lost", it's a bit misleading because it's not the receiver's content that is lost, it is the old contents of the *variable* that previously held the receiver that is now lost. The receiver (object) is 'lost', not the 'contents' of the receiver (object). #become:, as probably everyone agrees, must be the most subtle, yet at the same time the most enlightening feature of Smalltalk. Thanks -Panu Viljamaa |
Free forum by Nabble | Edit this page |