[squeak-dev] #valueWithExit inconsistency (?)

Marcel Taeumel marcel.taeumel at hpi.de
Wed Feb 17 16:52:22 UTC 2021


Hi Jaromir.

I added commentary via Kernel-mt.1370. I don't think that the (outer block's) return value should ever be used in this construct. It is more like a #detect: but without meaningful return values.

http://forum.world.st/explicit-return-from-a-block-tp51833.html

http://forum.world.st/The-Trunk-Kernel-ul-519-mcz-td3077583.html


I don't suppose it is idiomatic Smalltalk: "...but actually, I never had any reason to use this except when porting algorithms from Fortran or C... "


Best,
Marcel
Am 16.02.2021 14:05:23 schrieb Jaromir <m at jaromir.net>:
Current implementation of #valueWithExit seems a bit inconsistent in its
return value: it returns either nil (if the receiver exited using the exit
block) or the receiver.

Would it be worth modifying it to always return nil? (there are no senders
anyway)

valueWithExit
- self value: [ ^nil ]
+ ^self value: [ ^nil ]

Or using a nice complementary method #valueWithExit:

valueWithExit: aBlock
self value: [^aBlock value].
^aBlock value

valueWithExit
^self valueWithExit: [nil]

Thanks



-----
Jaromir
^[^
--
Sent from: http://forum.world.st/Squeak-Dev-f45488.html

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210217/17a3a37d/attachment.html>


More information about the Squeak-dev mailing list