Hi list, I bumped today with something which at least looks weird to me.
The problem boils down to: Object>>simpleTestOneWayBecome: otherObject self oneWayBecome: otherObject. self inspect. the weird thing to me is that the inspected object is otherObject and not the receiver. I know that one way become is supposed to replace all the references to the receiver with otherObject, but replacing self seems kind of extreme (also, the same applies to #become:) Also: self become: otherObject answers otherObject (since it ends with ^self) but self primBecome: otherObject answers the original receiver. Is this the expected behavior? Thanks in advance, Andrés _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Yes, it replaces self. Or rather, self, like every other
reference, now refers to that other thing. If you've done a one-way
become, then the original receiver is no longer reachable. That includes
self, references on the stack, everything.
The difference between become: and primBecome: seems a little odd, but is something that really shouldn't make much difference, since you wouldn't expect people to call primBecome: directly, and the indirect senders don't use the return value. At 05:58 PM 2009-11-13, andres wrote: Hi list, I bumped today with something which at least looks weird to me. --
Alan Knight [|], Engineering Manager, Cincom Smalltalk
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Hi Alan, thanks for the response. I understand that it replaces most
references (stack, owners, etc) but I always consider self as a "special" reference, not only because it is a pseudo variable, but because it represents the receiver of a message. I mean, thinking that the receiver of the message changes its self identity while the message is active is kind of weird to me, because now self isn't the object that actually received the message. I find it hard to put this into words since English is not my native language, but it seems strange to me from an OO-theory point of view. Anyway thanks for clearing this up. Cheers! Andrés Alan Knight escribió: > Yes, it replaces self. Or rather, self, like every other reference, now refers to that other thing. If you've done a one-way become, then the original receiver is no longer reachable. That includes self, references on the stack, everything. > > The difference between become: and primBecome: seems a little odd, but is something that really shouldn't make much difference, since you wouldn't expect people to call primBecome: directly, and the indirect senders don't use the return value. > > At 05:58 PM 2009-11-13, andres wrote: >> Hi list, I bumped today with something which at least looks weird to me. >> The problem boils down to: >> >> Object>>simpleTestOneWayBecome: otherObject >> >> self oneWayBecome: otherObject. >> self inspect. >> >> the weird thing to me is that the inspected object is otherObject and >> not the receiver. I know that one way become is supposed to replace all >> the references to the receiver with otherObject, but replacing self >> seems kind of extreme (also, the same applies to #become:) >> >> Also: >> >> self become: otherObject >> >> answers otherObject (since it ends with ^self) but >> >> self primBecome: otherObject >> >> answers the original receiver. >> >> Is this the expected behavior? >> >> Thanks in advance, >> Andrés >> _______________________________________________ >> vwnc mailing list >> [hidden email] >> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc > > -- > Alan Knight [|], Engineering Manager, Cincom Smalltalk > [hidden email] > [hidden email] > http://www.cincom.com/smalltalk > vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Yes, I'd say that there's a reasonable argument that become:
goes against OO theory in many respects. But having self be an exception
would open all kinds of interesting cases. Like, what happens if the
method returns self? Or even just uses it, but expects the method it just
called to have done something? The most common usage of become: is to
grow collections. If we wanted to add assertions to the language, is it
more intuitive when we say
aCollection>>addWithCheck: anObject self add: anObject. self assert: [self includes: anObject]. to have the assertion be true or false? If become: didn't affect the variable self, then it would be false. At 04:32 PM 2009-11-14, andres wrote: Hi Alan, thanks for the response. I understand that it replaces most --
Alan Knight [|], Engineering Manager, Cincom Smalltalk
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Hi Alan, thanks for you time. Even though I don't think that
implementation details (e.g. how collections are grown) should be the explanation for become:, your example is more than reasonable and I agree. I guess we learn something new every day :) Thanks again. Cheers, Andrés Alan Knight escribió: > Yes, I'd say that there's a reasonable argument that become: goes against OO theory in many respects. But having self be an exception would open all kinds of interesting cases. Like, what happens if the method returns self? Or even just uses it, but expects the method it just called to have done something? The most common usage of become: is to grow collections. If we wanted to add assertions to the language, is it more intuitive when we say > > aCollection>>addWithCheck: anObject > self add: anObject. > self assert: [self includes: anObject]. > > to have the assertion be true or false? If become: didn't affect the variable self, then it would be false. > > At 04:32 PM 2009-11-14, andres wrote: >> Hi Alan, thanks for the response. I understand that it replaces most >> references (stack, owners, etc) but I always consider self as a >> "special" reference, not only because it is a pseudo variable, but >> because it represents the receiver of a message. I mean, thinking that >> the receiver of the message changes its self identity while the message >> is active is kind of weird to me, because now self isn't the object that >> actually received the message. I find it hard to put this into words >> since English is not my native language, but it seems strange to me from >> an OO-theory point of view. >> Anyway thanks for clearing this up. >> >> Cheers! >> Andrés >> >> >> Alan Knight escribió: >>> Yes, it replaces self. Or rather, self, like every other reference, now refers to that other thing. If you've done a one-way become, then the original receiver is no longer reachable. That includes self, references on the stack, everything. >>> >>> The difference between become: and primBecome: seems a little odd, but is something that really shouldn't make much difference, since you wouldn't expect people to call primBecome: directly, and the indirect senders don't use the return value. >>> >>> At 05:58 PM 2009-11-13, andres wrote: >>>> Hi list, I bumped today with something which at least looks weird to me. >>>> The problem boils down to: >>>> >>>> Object>>simpleTestOneWayBecome: otherObject >>>> >>>> self oneWayBecome: otherObject. >>>> self inspect. >>>> >>>> the weird thing to me is that the inspected object is otherObject and >>>> not the receiver. I know that one way become is supposed to replace all >>>> the references to the receiver with otherObject, but replacing self >>>> seems kind of extreme (also, the same applies to #become:) >>>> >>>> Also: >>>> >>>> self become: otherObject >>>> >>>> answers otherObject (since it ends with ^self) but >>>> >>>> self primBecome: otherObject >>>> >>>> answers the original receiver. >>>> >>>> Is this the expected behavior? >>>> >>>> Thanks in advance, >>>> Andrés >>>> _______________________________________________ >>>> vwnc mailing list >>>> [hidden email] >>>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc >>> -- >>> Alan Knight [|], Engineering Manager, Cincom Smalltalk >>> [hidden email] >>> [hidden email] >>> http://www.cincom.com/smalltalk >>> >> _______________________________________________ >> vwnc mailing list >> [hidden email] >> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc > > -- > Alan Knight [|], Engineering Manager, Cincom Smalltalk > [hidden email] > [hidden email] > http://www.cincom.com/smalltalk > vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |