[squeak-dev] [BUG][FIX] Bug in WeakMessageSend

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Wed May 13 17:34:49 UTC 2009


2009/5/13 Juan Vuletich <juan at jvuletich.org>:
> Done. Mantis issue 7352. Please take a look at updated code.
>
> Comments interleaved...
>
> Nicolas Cellier wrote:
>>
>> Oh, and I forgot, correct class comment:
>>
>>  shouldBeNil            Array of: Boolean --  used to distinguish nil
>> arguments
>> from garbage collected arguments
>>
>>
>
> added
>
>> 2009/5/12 Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>:
>>
>>>
>>> Oops I did not understand the API at first glance...
>>> 3) was wrong because arguments are added first, and anArray last -
>>>
>>> One more thing: WeakActionSequence using isValid test is fragile too...
>>>
>>>
>
> It actually was not fragile, becuse it used the new safe methods in
> WeakMessageSend. What I did is to remove the #isValid tests.
>
>>> 2009/5/12 Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>:
>>>
>>>>
>>>> Yes sure, that was stupid!
>>>>
>>>> But:
>>>>
>>>> 1) #value & al used to return the value of evaluating the message, or
>>>> nil if any receiver/argument garbaged.
>>>> Now #value & al will always return self
>>>>
>
> fixed. thanks.
>
>>>> 2) #valueWithArguments: should not care if arguments were garbage
>>>> collected, because some replacement arguments were provided
>>>>
>
> What I did with this is to honor the old behavior. The (unwritten)
> specification is: "If the receiver or some argument is collected, then do
> nothing". Sounds reasonable, and I saw no reason to change this.
>

Sure, this is a very odd undocumented API, so it's hard to decide
whether a bug or not. Usage should be analyzed first.
My guess is that intention was to provide nil arguments where we don't
want Weakness, and replace these nils further with provided
replacement anArray... But the implementation is limited to these two
cases:
1) Weak arguments are all at the beginning and we use #valueWithEnoughArguments:
2) Weak arguments are all at the end and the shouldBeNil are all at
the beginning
The case of a Weak argument superseded by an element of anArray should
be a side effect hardly ever used, so I guess that does not much
matter to keep or change API in this special case.

In Pharo, I would recommend to deprecate and sweep this stuff (provide
a better API if necessary).
In distributions claiming maximum compatibility, I would recommend
keeping the API. But it's not ideal to be stucked on such kind of
code.

Nicolas

>>>> 3) #valueWithEnoughArguments: should care of garbage collected
>>>> arguments from: anArray size to: arguments size.
>>>>
>>>> Please publish a mantis report, then upload your updated code :)
>>>>
>>>> Cheers
>>>>
>>>>
>
> I also changed all _ to := , to ease integration in Croquet.
>
> Cheers,
> Juan Vuletich
>
>



More information about the Squeak-dev mailing list