<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. As you have probably heard, I am toying with adding eventual refs to Squeak. Unfortunately, they don't play well with non-local returns. Igor and I had been discussing what could be done with methods having non-local returns adn it is looking nasty. So I thought to look at another piece of the puzzle and question its existence. </DIV>
<DIV> </DIV>
<DIV>How important is non-local return to Squeak? What would Squeak look like without it?</DIV>
<DIV> </DIV>
<DIV>So I thought of the first use of it, detecting an object in a collection. Here is #detect:ifNone: with non-local return:</DIV>
<DIV> </DIV>
<DIV>detect: aBlock ifNone: exceptionBlock <BR> self do: [:each | (aBlock value: each) ifTrue: [^ each]].</DIV>
<DIV> ^ exceptionBlock value</DIV>
<DIV> </DIV>
<DIV>and here is a version without non-local return:</DIV>
<DIV> </DIV>
<DIV>detectNoNonLocalReturn: aBlock ifNone: exceptionBlock <BR> | foundElement index each |<BR> index := 1.<BR> [foundElement isNil and: [index <= self size]] whileTrue: [<BR> (aBlock value: (each := self at: index)) ifTrue: [foundElement := each].<BR> index := index + 1].<BR> ^ foundElement isNil<BR> ifTrue: [exceptionBlock value]<BR> ifFalse: [foundElement].</DIV>
<DIV><BR> </DIV>
<DIV>Hopefully someone can do better. As it stands it is much worse and I just don't know how to program in Squeak without non-local returns. It feels like there is a missing helper method in there or something. I don't know. 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. Noise.</DIV>
<DIV> </DIV>
<DIV>Tell me what you think!</DIV>
<DIV> </DIV>
<DIV>Cheers,</DIV>
<DIV>Rob</DIV>
<DIV> </DIV></DIV></div></body></html>