The Trunk: Kernel-tonyg.1344.mcz

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

The Trunk: Kernel-tonyg.1344.mcz

commits-2
Tony Garnock-Jones uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-tonyg.1344.mcz

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

Name: Kernel-tonyg.1344
Author: tonyg
Time: 8 October 2020, 11:35:47.705963 pm
UUID: d68b8946-be04-4e8c-9a2d-76e31736aa4b
Ancestors: Kernel-dtl.1343

Avoid explicit mention of Promise in a handful of places, preferring instead some means of specifying "the currently-relevant kind of Promise". Useful for subclasses of Promise.

=============== Diff against Kernel-dtl.1343 ===============

Item was changed:
  ----- Method: Promise class>>ifRejected: (in category 'instance creation') -----
  ifRejected: aBlock
+ ^ self basicNew initializeWithIfRejected: aBlock.!
- ^ Promise basicNew initializeWithIfRejected: aBlock.!

Item was changed:
  ----- Method: Promise class>>unit: (in category 'instance creation') -----
  unit: anObject
  "Return a resolved Promise. #new is the other half of Promise's unit function; #new returns an unresolved Promise."
+ ^ self basicNew initializeWithResolvedValue: anObject.!
- ^ Promise basicNew initializeWithResolvedValue: anObject.!

Item was changed:
  ----- Method: Promise>>then:ifRejected: (in category 'monad') -----
  then: resolvedBlock ifRejected: errBlock
  "Return a Promise that, if it resolves, runs the resolvedBlock. If resolution throws an Exception, it runs the errBlock."
  | p |
+ p := self species new.
- p := Promise new.
  resolvedBlock
  ifNil: [self whenResolved: [:v | p resolveWith: v]]
  ifNotNil: [
  self whenResolved: [:v |
  [p resolveWith: (resolvedBlock value: v)]
  on: Error do: [:e | p rejectWith: e]]].
  errBlock
  ifNil: [self whenRejected: [:e | p rejectWith: e]]
  ifNotNil: [
  self whenRejected: [:e |
  [p resolveWith: (errBlock value: e)]
  on: Error do: [:e2 | p rejectWith: e2]]].
  ^ p.!