[squeak-dev] The Trunk: Kernel-tonyg.1331.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Jun 4 20:01:15 UTC 2020


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

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

Name: Kernel-tonyg.1331
Author: tonyg
Time: 4 June 2020, 7:51:24.268037 pm
UUID: b7790e35-7fff-4def-89ef-2a6f8534ca20
Ancestors: Kernel-tonyg.1330

More repairs to Promise to bring it closer to Promise/A+ behaviour.

=============== Diff against Kernel-tonyg.1330 ===============

Item was changed:
  ----- Method: Promise>>ifRejected: (in category 'monad') -----
  ifRejected: errBlock
+ 	^ self then: nil ifRejected: errBlock!
- 	^ self then: [:ignored | "Do nothing"] ifRejected: errBlock.!

Item was changed:
  ----- Method: Promise>>then: (in category 'monad') -----
  then: resolvedBlock
+ 	^ self then: resolvedBlock ifRejected: nil!
- 	^ self then: resolvedBlock ifRejected: [:e | "Pass rejection reason along" e].!

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 := 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]]].
- 	self whenResolved: [:v |
- 		[p resolveWith: (resolvedBlock value: v)]
- 			on: Error do: [:e | p rejectWith: e]].
- 	self whenRejected: [:e |
- 		[p resolveWith: (errBlock value: e)]
- 			on: Error do: [:e2 | p rejectWith: e2]].
  	^ p.!



More information about the Squeak-dev mailing list