<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<DIV>I'll just throw this out and see what turns up.&nbsp;&nbsp; As you have probably heard, I am toying with adding eventual refs to Squeak.&nbsp; Unfortunately, they don't play well with non-local returns.&nbsp; Igor and I had been discussing what could be done with methods having non-local returns adn it is looking nasty.&nbsp;&nbsp; So I thought to look at another piece of the puzzle and question its existence.&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>How important is non-local return to Squeak?&nbsp;&nbsp;What would Squeak look like without it?</DIV>
<DIV>&nbsp;</DIV>
<DIV>So I thought of the first use of it, detecting an object in a collection.&nbsp; Here is #detect:ifNone: with non-local return:</DIV>
<DIV>&nbsp;</DIV>
<DIV>detect: aBlock ifNone: exceptionBlock&nbsp;<BR>&nbsp;&nbsp;&nbsp; self do: [:each | (aBlock value: each) ifTrue: [^ each]].</DIV>
<DIV>&nbsp;&nbsp;&nbsp; ^ exceptionBlock value</DIV>
<DIV>&nbsp;</DIV>
<DIV>and here is a version without non-local return:</DIV>
<DIV>&nbsp;</DIV>
<DIV>detectNoNonLocalReturn: aBlock ifNone: exceptionBlock&nbsp;<BR>&nbsp;&nbsp;&nbsp; | foundElement index each |<BR>&nbsp;&nbsp;&nbsp; index := 1.<BR>&nbsp;&nbsp;&nbsp; [foundElement isNil and: [index &lt;= self size]] whileTrue: [<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (aBlock value: (each := self at: index)) ifTrue: [foundElement := each].<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; index := index + 1].<BR>&nbsp;&nbsp;&nbsp; ^ foundElement isNil<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ifTrue: [exceptionBlock value]<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ifFalse: [foundElement].</DIV>
<DIV><BR>&nbsp;</DIV>
<DIV>Hopefully someone can do better.&nbsp; As it stands it is much worse and I just don't know how to program in Squeak without non-local returns.&nbsp; It feels like there is a missing helper method in there or something.&nbsp; I don't know.&nbsp; At the point of detection we know we want to return that thing and the rest of this mathod just transfers it down to the end of the method.&nbsp; Noise.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Tell me what you think!</DIV>
<DIV>&nbsp;</DIV>
<DIV>Cheers,</DIV>
<DIV>Rob</DIV>
<DIV>&nbsp;</DIV></DIV></div></body></html>