[squeak-dev] The Inbox: Tools-btc.367.mcz

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Mon Jul 11 17:12:23 UTC 2011


2011/7/11 <commits at source.squeak.org>

> A new version of Tools was added to project The Inbox:
> http://source.squeak.org/inbox/Tools-btc.367.mcz
>
> ==================== Summary ====================
>
> Name: Tools-btc.367
> Author: btc
> Time: 12 July 2011, 12:07:30.194 am
> UUID: bdc1afda-eed5-904b-9987-572aac977a16
> Ancestors: Tools-bf.366
>
> Single stepping through debugger can observe an anOrderedCollection object
> in an inconsistent state after creation but before initialisation.  This
> threw an error when the inspector asked for the size of the object - now
> handled.
>
> =============== Diff against Tools-bf.366 ===============
>
> Item was changed:
>  ----- Method: OrderedCollectionInspector>>fieldList (in category 'as yet
> unclassified') -----
>  fieldList
>        object ifNil: [ ^ OrderedCollection new].
>        ^ self baseFieldList ,
> +               (self objectSize <= (self i1 + self i2)
> +                       ifTrue: [(1 to: self objectSize)
> -               (object size <= (self i1 + self i2)
> -                       ifTrue: [(1 to: object size)
>                                                collect: [:i | i
> printString]]
> +                       ifFalse: [(1 to: self i1) , (self objectSize -
> (self i2-1) to: self objectSize)
> -                       ifFalse: [(1 to: self i1) , (object size-(self
> i2-1) to: object size)
>                                                collect: [:i | i
> printString]])
>  "
>  OrderedCollection new inspect
>  (OrderedCollection newFrom: #(3 5 7 123)) inspect
>  (OrderedCollection newFrom: (1 to: 1000)) inspect
>  "!
>
>
I understand, OrderedCollection new inspect won't fail.
But you can't debugIt step by step, because just after basicNew, it will be
uninitialized.


> Item was added:
> + ----- Method: OrderedCollectionInspector>>objectSize (in category 'as yet
> unclassified') -----
> + objectSize
> +       "Single stepping through a debugger can observe the object state
> after creation but before initiialisation."
> +       "Thus 'object size' may throw an axception for trying to do
> arithmetic on nil."
> +
> +        [ object size ] on: Exception do: [ ^ 0 ].
> +        ^ object size.!
>

Is it a good idea to catch all Exception ?
Otherwise, there is no reason to invoke size twice, it just could be
^ [ object size ] on: Error do: [ 0 ]

Nicolas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20110711/4dd92dbb/attachment.htm


More information about the Squeak-dev mailing list