[squeak-dev] `ensure:` ... doesn't (in some circumstances involving nesting `ensure:` blocks in `ensure:` handlers).

Tony Garnock-Jones tonyg at leastfixedpoint.com
Thu Nov 4 09:56:38 UTC 2021


Also of note: using `self halt` to debug `ensure:` blocks is made 
difficult by this! (Because the process just... disappears!)

On 11/4/21 09:59, Tony Garnock-Jones wrote:
> Here's an example of where `ensure:` doesn't quite do what it says on 
> the tin:
> 
>      [
>        [Processor activeProcess terminate] ensure: [
>          Transcript cr; show: 'outer1'.
>          [nil error: 'aiee'] ensure: [Transcript cr; show: 'inner'].
>          Transcript cr; show: 'outer2'.
>        ]
>      ] fork
> 
> Expected output:
> 
>      outer1
>      (debugger appears; click 'abandon')
>      inner
> 
> (or possibly:
> 
>      outer1
>      (debugger appears; click 'abandon')
>      inner
>      outer2
> 
> which is what you get if you change "Processor activeProcess terminate" 
> to "1 + 2" above... but this also seems odd.)
> 
> Actual output:
> 
>      outer1
>      (no debugger appears, nothing more happens)
> 
> Are my expectations out-of-line, or is there a problem worth 
> investigating here?
> 
> "--"
> 
> I think it's worth noting that a related program:
> 
>      [
>        [Processor activeProcess terminate] ensure: [
>          [
>            Transcript cr; show: 'outer1'.
>            [nil error: 'aiee'] ensure: [
>              Transcript cr; show: 'inner'].
>            Transcript cr; show: 'outer2'.
>          ] on: Error do: [:ex | Transcript cr; show: ex]
>        ]
>      ] fork
> 
> yields the reasonable output
> 
>      outer1
>      Error: aiee
>      inner
> 
> Cheers,
>    Tony
> 


More information about the Squeak-dev mailing list