<div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
                                        Hi Jaromir.<div><br></div><div><span style="font-size: 10pt">> </span><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">How can I convince you?</span><br></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Well, I understand the issue that you described. However, I think it is very bad style to return from within an ensure-block. That's why I would like to set the urgency for this to "rather low". :-)</span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">The idiom for using #ensure: in the return-expression is this:</span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">^ aBlock ensure: ensureBlock</span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">^ [ self doTrickyStuff ] ensure: [ self cleanUp ]</span><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></span></div><div><br></div><div>That is, you should only use *inner* returns to get out early. And then, the ensure will clean up after you.</div><div><br></div><div>If you really would want to "ensure" a certain return value, you could do it like this:</div><div><br></div><div>| result |</div><div>[ self doTrickyStuff ] ensure: [ result := 42 ].</div><div>^ result</div><div><br></div><div>But why using #ensure: at all for such a case? If you think that exceptions might happen, you would have to wrap it this way:</div><div><br></div><div>| result |</div><div>result := 42.</div><div>[ self doTrickyStuff ] on: KnownError do: [ :ex | "Ignore." ].</div><div>^ result</div><div><br></div><div>Well, doesn't make much sense to me. :-) You clean up resources (i.e. state) via #ensure: when facing exceptions. You do not manage control flow through it. The exception handlers #on:do: are for that.</div><div><br></div><div>Do not put a return "^" into an ensure block.</div><div><br></div><div>Best,</div><div>Marcel</div><div><br></div><div class="mb_sig"></div>
                                        <blockquote class="history_container" type="cite" style="border-left-style: solid;border-width: 1px;margin-top: 20px;margin-left: 0px;padding-left: 10px;min-width: 500px">
                        <p style="color: #AAAAAA; margin-top: 10px;">Am 15.03.2021 21:54:47 schrieb Jaromir Matas <m@jaromir.net>:</p><div style="font-family:Arial,Helvetica,sans-serif">Hi Marcel,<br><br>>> In this discussion, you should always specify whether "responds to"<br>>> involves a sender within a simulated or genuine "context". ;-) I am still<br>>> not convinced that this is an actual problem.<br><br>Sorry for confusing you, this all new to me :)<br><br>How can I convince you? I debug quite naively, no fancy stuff. I'll try<br>again to show the exact steps replicating the issue using Christoph's<br>example:<br><br>0. downloaded the latest trunk image<br>Squeak6.0alpha-20304-64bit-202003021730-Windows with Kernel-mt.1381<br>1. open Process Browser with auto-update on<br>2. open an explorer window on the current UI process to watch it<br>3. do-it `[self error: 'e1'] ensure: [^2]` in a Workspace<br><br>Now three things happened, as expected (screenshot 1):<br>a) an Error debugger window popped up<br>a) the UI process has become suspended<br>b) a new UI has been created<br><br>4. open an explorer window on the new UI process to watch it<br>5. Abandon the Error window <br><br>And now a couple of highly surprising things happened (screenshot 2):<br>d) Error window disapeared - that's still expected but<br>e) the new UI process (88230) disappeared from the Process Browser - NOT<br>expected<br>    AND became the genuineProcess - expected<br>    AND it responds true to isTerminated sent to self in its Explorer window<br>- NOT expected<br>f) the old UI process (48259) became the current UI process - NOT expected<br>     AND became the effectiveProcess - NOT expected<br>     AND responds true to isActiveProcess sent to self in its Explorer<br>window - confusing<br><br>At this point however the genuine process is indeed not terminated but<br>executing. It is not shown on the Process Browser however because it filters<br>out terminated processes. You can verify this by changing first line in<br>isTerminated, for a moment, to:<br><br>    (self isActiveProcess or: [self effectiveProcess == Processor<br>activeProcess]) ifTrue: [^ false].<br><br>And now everything runs as usual as if nothing happened except the really<br>executing process is hidden from your view and the formerly debugged process<br>acts as the active process but is not really executing (see screenshot 3<br>with the invisible process 88230 shown).<br><br>6. now I reverted isTerminated back to original and did Christoph's do-it<br>`self error`<br><br>And the rest went as Christoph described; I'd just like to point out the<br>hidden process 88230 now reappears as the current UI process and correctly<br>responds true to isActiveProcess e.g. in the Explorer window. In case you<br>hit Proceed on the Unwind error window the two UI processes above will start<br>alternating because they are now both runnable in the priority 40 queue.<br><br>I find this course of events very unexpected; trying to follow using the<br>standard tools is very confusing - namely the disappearing genuine process.<br>I know it's due to the bug Christoph discovered and described but the tools<br>should rather reveal, not hide information vital for understanding what's<br>happening :)<br><br>I apologize for such a long description and sincerely hope I haven't made<br>any error here to waste your time.<br><br>Thanks,<br><br>Screenshot1.png <http: forum.world.st="" file="" t372955="" screenshot1.png="">  <br>Screenshot2.png <http: forum.world.st="" file="" t372955="" screenshot2.png="">  <br>Screenshot3.png <http: forum.world.st="" file="" t372955="" screenshot3.png="">  <br><br><br><br>-----<br>^[^ Jaromir<br>--<br>Sent from: http://forum.world.st/Squeak-Dev-f45488.html<br><br></http:></http:></http:></div></blockquote></div>