On 15 September 2011 14:20, Lukas Renggli <[email protected]> wrote:
>>> How would you write the following method in Scheme (assuming that
>>> there is something like a #at:ifAbsent: in Scheme)?
>>>
>>>    Object>>foo
>>>      bar := zork at: 1 ifAbsent: [ ^ 2 ].
>>>      self andNowForSomethingCompletelyDifferent: bar.
>>
>> Either use a continution (call/cc), or check whether 1 is in zork, or check 
>> if looking for 1 return nil. But basically, it is likely that you will have 
>> one function for the the lookup, and another that does the 
>> andNowForSomethingCompletelyDifferent:.
>
> You are changing the example, you were supposed to use #at:ifAbsent: :-)
>
> So this tells us what we all expected: If there is non-local return,
> people use other patterns. I doubt though that this generally leads to
> smaller methods or easier to understand code.

s/non-local/no non-local/

Lukas


-- 
Lukas Renggli
www.lukas-renggli.ch

Reply via email to