[squeak-dev] miss-used become: ???

Bert Freudenberg bert at freudenbergs.de
Sat Jun 9 15:53:15 UTC 2012


On 2012-06-09, at 17:33, Chris Muller wrote:

> So the whole method would seem to be useless then..

No. It changes the player from an unscripted one into one that can have scripts.

The return value of assureUniClass is not used in the system, so it doesn't really matter.

However, I agree with Nicolas that becomeForward: would be more appropriate. In particular since the code reads like returning the new instance was the intention.

- Bert -



> On Sat, Jun 9, 2012 at 10:17 AM, Nicolas Cellier
> <nicolas.cellier.aka.nice at gmail.com> wrote:
>> Try this
>> 
>> String>>becomeB
>>    self become: 'b'.
>>    ^self first
>> 
>> ^'a' becomeB
>> 
>> Nicolas
>> 
>> 2012/6/9 Chris Muller <asqueaker at gmail.com>:
>>> Does become: swap the references in the currently executing MethodContext too?
>>> 
>>> 
>>> On Fri, Jun 8, 2012 at 4:34 PM, Nicolas Cellier
>>> <nicolas.cellier.aka.nice at gmail.com> wrote:
>>>> UnscriptedPlayer>>assureUniClass
>>>>        "Create a uniclass and become the receiver into it"
>>>> 
>>>>        | anInstance |
>>>>        anInstance := self rootClassForUniclasses instanceOfUniqueClass.
>>>>        anInstance initializeCostumesFrom: self.
>>>>        self become: anInstance.
>>>>        ^ anInstance
>>>> 
>>>> As I understand it, after the become: self is anInstance and anInstance is self.
>>>> So this would answer the original UnscriptedPlayer before the become...
>>>> Is this really the intention?
>>>> Otherwise, becomeForward: would work better.
>>>> 
>>>> Nicolas
>>>> 
>>> 
>> 
> 



More information about the Squeak-dev mailing list