The Inbox: Kernel-ct.1321.mcz

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

The Inbox: Kernel-ct.1321.mcz

commits-2
A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-ct.1321.mcz

==================== Summary ====================

Name: Kernel-ct.1321
Author: ct
Time: 9 April 2020, 7:55:56.724949 pm
UUID: 6f8c6c8d-a379-5f46-b774-587e81ddb067
Ancestors: Kernel-eem.1319

Integrates ModificationForbidden into Error hierarchy. This makes ModificationForbidden catchable by #ifError:, TestResult exError and others. See also: http://forum.world.st/Why-is-ModificationForbidden-not-an-Error-td5114717.html

Further refactorings applied:
- Update class comment (use Smalltalk-typical format, update instvar names and don't hardcode their count)
- Use #translated and #format: for message texts
- Update method comment of #resume which was copied from Context

=============== Diff against Kernel-eem.1319 ===============

Item was changed:
+ Error subclass: #ModificationForbidden
- Exception subclass: #ModificationForbidden
  instanceVariableNames: 'mirror object fieldIndex newValue retrySelector resumptionValue'
  classVariableNames: ''
  poolDictionaries: ''
  category: 'Kernel-Exceptions'!
 
+ !ModificationForbidden commentStamp: 'ct 4/9/2020 19:49' prior: 0!
+ This error is raised when attempting to mutate a read-only object.
- !ModificationForbidden commentStamp: 'eem 3/11/2020 15:46' prior: 0!
- This exception is raised when attempting to mutate a read-only object.
 
+ My instances describe the necessary state to be able to reproduce the modification via the #retryModification protocol.
- My instances have 5 fields to be able to reproduce the modification via the retryModification method.
 
+ Instance Variables
+ mirror: <Context | Behavior | Array>
+ object: <Object>
+ fieldIndex: <SmallInteger | nil>
+ newValue: <Object>
+ resumptionValue: <Object>
+ retrySelector: <Symbol>
+
+ mirror
+ - the object that will perform the modification on object if modificationRetried
+
+ object
+ - read-only object that attempted to mutate
+
+ fieldIndex
+ - index of the field in the object mutated, relevant for the corresponding selector
+
+ newValue
+ - value that was attempted to be stored into the read-only object
+
+ resumptionValue
+ - value that will be returned when the ModificationForbidden is resumed
+
+ retrySelector
+ - selector that can be used to reproduce the mutation (#object:basicAt:put:, #object:instVarAt:put:, etc.)!
- mirror <Context|Behavior|Array> the object that will perform the modification on object if modificationRetried
- object <Object> read-only object that attempted to mutate
- index <SmallInteger | nil> index of the field in the object mutated, relevant for the corresponding selector
- value <Object> value that was attempted to be stored into the read-only object
- selector <Symbol> selector that can be used to reproduce the mutation (#object:basicAt:put:, #object:instVarAt:put:, etc)!

Item was removed:
- ----- Method: ModificationForbidden>>defaultAction (in category 'priv handling') -----
- defaultAction
- UnhandledError signalForException: self!

Item was changed:
  ----- Method: ModificationForbidden>>indexedMessageText (in category 'printing') -----
  indexedMessageText
+
+ ^ 'Cannot modify field {2} of read-only object {1}' translated
+ format: {
+ self printObject: object.
+ fieldIndex }!
- ^String streamContents:
- [ :s |
- s << ' '.
- self printObject: object on: s.
- s << ' is read-only, hence its field '.
- fieldIndex printOn: s.
- s << ' cannot be modified with '.
- self printObject: newValue on: s]!

Item was added:
+ ----- Method: ModificationForbidden>>isResumable (in category 'priv handling') -----
+ isResumable
+
+ ^ true!

Item was changed:
  ----- Method: ModificationForbidden>>nonIndexedMessageText (in category 'printing') -----
  nonIndexedMessageText
+
+ ^ 'Cannot execute {2} on read-only object {1}' translated
+ format: {
+ self printObject: object.
+ retrySelector printString }!
- ^String streamContents:
- [ :s |
- s << ' '.
- self printObject: object on: s.
- s << ' is read-only, hence its selector '.
- s << retrySelector.
- s << ' cannot be executed with '.
- self printObject: newValue on: s]!

Item was added:
+ ----- Method: ModificationForbidden>>printObject: (in category 'private') -----
+ printObject: obj
+
+ ^ [obj printString]
+ ifError: ['<cannot print object>' translated]!

Item was removed:
- ----- Method: ModificationForbidden>>printObject:on: (in category 'printing') -----
- printObject: obj on: s
- [obj printOn: s]
- on: Exception
- do: [ :ex | s << '<cannot print object>' ]!

Item was changed:
  ----- Method: ModificationForbidden>>resume (in category 'controlling') -----
  resume
+ "Return from the message that signaled the receiver."
- "Roll back thisContext to self and resume.  Execute unwind blocks when rolling back.  ASSUMES self is a sender of thisContext"
 
+ ^ self resume: resumptionValue!
- self resume: resumptionValue!