[squeak-dev] Re: #ensure: What would you expect?
Andreas Raab
andreas.raab at gmx.de
Fri Dec 2 16:17:50 UTC 2011
There is only one possibly correct answer which is raising
BlockCannotReturn, because we're trying to return while we're in the
midst of returning already, so there is no place to return to. That
answer is implemented by the attached change set.
BTW, the code duplication between ContextPart>>restart
ContextPart>>resume:, ContextPart>>unwindTo:, and Process>>terminate
bothers me greatly. The change set only fixes one of these locations
(the one triggered by your problem statement) but having such critical
code duplicated all over the places can't be good. Any takers?
Cheers,
- Andreas
On 12/2/2011 15:18, Tobias Pape wrote:
> Dear All,
>
> given the following class:
>
> Object subclass: #Foo
> instanceVariableNames: ''
> classVariableNames: ''
> poolDictionaries: ''
> category: 'Foo'!
> a
> self b: [^ 1].! !
>
> b: aBlock
>
> [self c: aBlock] ensure: [^ 2].
>
> c: aBlock
>
> aBlock value.
> ^ 3
>
> And you would do
>
> Foo new a
>
> what would you expect?
>
> I am very curious.
> Please, first guess, then execute.
>
> Best
> -Tobias
>
>
>
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ContextPart-resume.st
Type: application/x-st
Size: 855 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20111202/543c781c/ContextPart-resume.bin
More information about the Squeak-dev
mailing list
|