[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 08:59:05 UTC 2021


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