What would Squeak be like without non-local returns

Rob Withers reefedjib at yahoo.com
Wed Nov 7 01:16:37 UTC 2007

Are you saying you couldn't do without this feature?  I have to agree, but 
still the question is worth asking.

----- Original Message ----- 
From: "nicolas cellier" <ncellier at ifrance.com>
To: <squeak-dev at lists.squeakfoundation.org>
Sent: Tuesday, November 06, 2007 4:03 PM
Subject: Re: What would Squeak be like without non-local returns

> Rob, ask this to a Compiler, an interpreter, but not to a Smalltalk 
> programmer please!
> Rob Withers a écrit :
>> 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. How important is non-local return to 
>> Squeak?  What would Squeak look like without it?
>>  So I thought of the first use of it, detecting an object in a 
>> collection.  Here is #detect:ifNone: with non-local return:
>>  detect: aBlock ifNone: exceptionBlock self do: [:each | (aBlock value: 
>> each) ifTrue: [^ each]].
>>     ^ exceptionBlock value
>>  and here is a version without non-local return:
>>  detectNoNonLocalReturn: aBlock ifNone: exceptionBlock | foundElement 
>> index each |
>>     index := 1.
>>     [foundElement isNil and: [index <= self size]] whileTrue: [
>>         (aBlock value: (each := self at: index)) ifTrue: [foundElement := 
>> each].
>>         index := index + 1].
>>     ^ foundElement isNil
>>         ifTrue: [exceptionBlock value]
>>         ifFalse: [foundElement].
>>  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.
>>  Tell me what you think!
>>  Cheers,
>> Rob
>>  ------------------------------------------------------------------------

More information about the Squeak-dev mailing list