On Tue, Jul 19, 2011 at 8:19 AM, Camillo Bruni <camillo.bruni@inria.fr>wrote:
Can anyone explain me why it would make sense to use #return: in the following method?
TestCase >> executeShould: aBlock inScopeOf: anExceptionalEvent ^[aBlock value. false] on: anExceptionalEvent do: [:ex | ex return: true]
I would instinctively replace [:ex | ex return: true] with the much simpler [:ex | ^ true].. Am I missing something here?
Well, Lukas' answer makes sense to me. But on a style point I would replace it by the even simpler TestCase >> executeShould: aBlock inScopeOf: anExceptionalEvent ^[aBlock value. false] on: anExceptionalEvent do: [:ex | true] the explicit non-local return ^true isn't necessary, sicne there's already a method return for the whole on:do: form, and in some implementations the [:ex| ^true] block could be significantly more expensive to create than [:ex| true] (e.g. VisualWorks, but not current Squeak/Pharo with my closure implementation).
camillo
-- best, Eliot