The Inbox: Tools-btc.367.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Tools-btc.367.mcz

commits-2
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
  "!

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.!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Tools-btc.367.mcz

Nicolas Cellier


2011/7/11 <[hidden email]>
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


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Tools-btc.367.mcz

Ben Coman
Nicolas Cellier wrote:


2011/7/11 <[hidden email]>
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.
Thats right, I could not debug past the basicNew and through the 'setCollection:' initialization, but I expect to be able to. I was debugging some code step-by-step, which happened to create a new OrderCollection, which caused the debugger to produce a DoesNotUnderstand error that I could not get past.  This can be simulated by...   'self halt. OrderedCollection new: 5.'

What now is the status of my two Inbox submissions?  I assume they are rejected but it doesn't specifically say so. 
Do you correct them as necessary to push them forward? Or do I resubmit new ones taking on board the feedback from yourself and Levente?
 
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




Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Tools-btc.367.mcz

Nicolas Cellier

2011/7/12 Ben Coman <[hidden email]>
Nicolas Cellier wrote:


2011/7/11 <[hidden email]>
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.
Thats right, I could not debug past the basicNew and through the 'setCollection:' initialization, but I expect to be able to. I was debugging some code step-by-step, which happened to create a new OrderCollection, which caused the debugger to produce a DoesNotUnderstand error that I could not get past.  This can be simulated by...   'self halt. OrderedCollection new: 5.'

What now is the status of my two Inbox submissions?  I assume they are rejected but it doesn't specifically say so. 
Do you correct them as necessary to push them forward? Or do I resubmit new ones taking on board the feedback from yourself and Levente?

I suggest you resubmit, your contribution is welcomed!

Nicolas
 
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