The Trunk: Kernel-mt.1371.mcz

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

The Trunk: Kernel-mt.1371.mcz

commits-2
Marcel Taeumel uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-mt.1371.mcz

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

Name: Kernel-mt.1371
Author: mt
Time: 17 February 2021, 5:56:29.152426 pm
UUID: 1e5b05c3-feb7-e945-a253-3218ee358e74
Ancestors: Kernel-mt.1370

Extracts better examples for #valueWithExit from squeak-dev mailing list.

=============== Diff against Kernel-mt.1370 ===============

Item was changed:
  ----- Method: BlockClosure>>valueWithExit (in category 'evaluating') -----
  valueWithExit
+ "Provides an exit block to the receiver. Use it to break out of the control flow with an early return. Examples below.
+ [:break | 1 to: 10 do: [:each | each > 5 ifTrue: [break value]]] valueWithExit.
+ 1 to: 10 do: [:each | [:continue | each > 5 ifTrue: [continue value]] valueWithExit]."
- "Provides an exit block to the receiver. Use it to break out of the control flow with an early return. For example:
- [:exit | 1 to: 10 do: [:each | each > 5 ifTrue: [exit value]]] valueWithExit"
   self value: [ ^nil ]!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-mt.1371.mcz

Christoph Thiede

Cool, nice utility - even though it does not support good readability of your code for sure :-) I have always used "thisContext return" for a similar result. :-D


What about supporting a return argument here as well, like:

self value: [ :ret | ^ ret ]

?


This could increase the usefulness of #valueWithExit, but on the other hand, all clients would need to send #cull: or #value:. Any opinions? :-)


Best,

Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Mittwoch, 17. Februar 2021 17:56:32
An: [hidden email]; [hidden email]
Betreff: [squeak-dev] The Trunk: Kernel-mt.1371.mcz
 
Marcel Taeumel uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-mt.1371.mcz

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

Name: Kernel-mt.1371
Author: mt
Time: 17 February 2021, 5:56:29.152426 pm
UUID: 1e5b05c3-feb7-e945-a253-3218ee358e74
Ancestors: Kernel-mt.1370

Extracts better examples for #valueWithExit from squeak-dev mailing list.

=============== Diff against Kernel-mt.1370 ===============

Item was changed:
  ----- Method: BlockClosure>>valueWithExit (in category 'evaluating') -----
  valueWithExit
+        "Provides an exit block to the receiver. Use it to break out of the control flow with an early return. Examples below.
+                [:break | 1 to: 10 do: [:each | each > 5 ifTrue: [break value]]] valueWithExit.
+                1 to: 10 do: [:each | [:continue | each > 5 ifTrue: [continue value]] valueWithExit]."
-        "Provides an exit block to the receiver. Use it to break out of the control flow with an early return. For example:
-                [:exit | 1 to: 10 do: [:each | each > 5 ifTrue: [exit value]]] valueWithExit"
           self value: [ ^nil ]!




Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-mt.1371.mcz

Jaromir Matas
Really nice! I'd just add a return to behave like a normal #value in case the
non-local return doesn't happen:

^self value: [ :ret | ^ ret ]

Thanks,



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

^[^ Jaromir