[Vm-dev] Object>>#at:put: reports improper store when everything seems fine

André Wendt andre.wendt at hpi.uni-potsdam.de
Sat Apr 5 17:32:18 UTC 2008


Andreas Raab wrote:
> 
> André Wendt wrote:
>> I just stumble upon this: Object>>#at:put: calls <primitive:61>. If that
>> fails, the following lines read
>>
>> index isInteger ifTrue:
>>     [self class isVariable
>>         ifTrue: [(index >= 1 and: [index <= self size])
>>             ifTrue: [self errorImproperStore]
>>
>> Why is it an improper store if the index is an integer, the receiver
>> class is variable, and the index is within bounds? Someone please
>> enlighten me...
> 
> Because it's the only failure mode that's left. It happens when you
> create non-pointer subclasses, for example:
> 
> Object variableWordSubclass: #MyWordArray
>     instanceVariableNames: ''
>     classVariableNames: ''
>     poolDictionaries: ''
>     category: 'Sample-Objects'
> 
> and now:
> 
> wa := MyWordArray new: 10.
> wa at: 1 put: 0. "works"
> wa at: 2 put: nil. "fails"
> wa at: 3 put: -1. "fails"
> wa at: 4 put: 16r100000000. "fails"
> wa at: 5 put: Smalltalk. "fails"
> 
> etc.
> 
>> (If this is merely reporting "there was an error in the primitive
>> although everything's alright", then I feel the message should be
>> something other than "Improper store into indexable object".)
> 
> Think about this for a second. What possible other failure mode could
> there be in the at:put: primitive?

I guess you're right. It really *is* the only failure mode left.

Best,
André


More information about the Vm-dev mailing list