[GRR] OutOfScopeNotification catching caught me
nicolas cellier
ncellier at ifrance.com
Fri Apr 7 22:46:44 UTC 2006
evaluate this silly example from a text editor:
Object compile: 'outOfScopeExample
true ifTrue: [| i | i := 1].
^i'.
^Object new perform: #outOfScopeExample
Well surprise, it compiles...
It doesn't raise a SyntaxErrorNotification because the OutOfScopeNotification
is caught by ParagraphEditor evaluateSelection... Instead, above evaluation
will answer 1. Gasp, not a thing to teach in schools !
Now try to write this code in a SUnit, the SUnit will fail when ran from the
TestRunner, but will succeed when ran from the browser (evaluating something
like self debug: #testOutOfScope). You see, things are getting worse...
I nearly turned crazy on a related bug : I subclassed MessageAsTempNode which
answers -1 when sent #scope, which cause an out of scope Notification.
Of course, i wrote SUnit tests that all ran fine when launched from the
browser (sorry, i'am used to VW RB interface, where i enforced good habits to
write and run tests immediately, not spending several clicks to open a
separate TestRunner and select my TestCase. TestRunner is good for massive
non regression tests, it is not tailored for Xtreme Programming).
MessageAsTempNode is used by inspector/debugger to compile contextual
evaluations... and compiler generates an out of scope notification when it
encounters such a contextual variable (i'am not sure that this is correct
because thisContext is not out of scope)... Fortunately, debugger and
inspector are interactive things, so ParagraphEditor trick catch that and
make it work finally... Is this real programmer's intention, or just lucky
circumstances?
Exception handling sometimes look sexy, but deserve special care. Putting it
in a central place like ParagraphEditor, you can expect creating undesired
side effects... Unless all this is desired ?
Nicolas
More information about the Squeak-dev
mailing list
|