Assume we have the following sequence of methods:
m1
self m2: [^1]
m2: block
self m3: block.
Processor := nil "crash!"
m3: block
[block value] ensure: [^2]
The question is what's the value of anObject m1
?
In other words, is the semantics of [ˆ2]
well defined as an ensured block? There are two possibilities:
m1
will return with 1
.Please note that I'm not asking what will happen. I'm rather interested in the definition of the execution flow.
EDIT
COROLLARY 1 (as confirmed by Lukas in his answer below): Not a good programming style!
Check page 23 of the Draft of ANSI Smalltalk Standard that describes the return statement and its interaction with ensure:
blocks:
If the evaluation of a termination block concludes with the execution of a return statement the result is undefined.