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

Marcel Taeumel marcel.taeumel at hpi.de
Fri Jun 5 05:59:17 UTC 2020


Hi Tony!

Thank you for caring for Squeak's promises! :-D

Best,
Marcel
Am 04.06.2020 22:01:23 schrieb commits at source.squeak.org <commits at source.squeak.org>:
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.!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200605/8bd74575/attachment.html>


More information about the Squeak-dev mailing list