[Q] Compiler evaluate: question

John W. Sarkela sarkela at sbcglobal.net
Wed May 21 19:09:00 UTC 2003


NEVER, NEVER, and once again *NEVER* use #ifError:
This protocol was introduced prior to exceptions existing in the
base image. It was made exception aware by capturing the exception,
Error. This is very, very, very bad form. (I have written about this
on more than one occasion, check the archives.)

The problem is that the idiom...

[<long involved computation>]
	on: Error
	do: [:ex | <handler code>]

will prevent anyone deeper in the call chain (or the default handler)
from having an opportunity to rectify the exceptional condition. There
was a case in the Win32s implementation of VSE in which an OS bug
was worked around by having a default FileError handler that could
reliably recover from error indications returned from the OS.

Instead, one should wait till *all* handlers have had an opportunity
to attempt recovery, if they can't and the call chain must be unwound,
one would catch instead the fact that the call chain is being 
prematurely
cut short with the following idiom...

[<long involved computation>]
	ifCurtailed: [<termination cleanup code>]

As for the specific case of the compiler, I believe I have heard our
friends in Berne lament the direct reference to morphs in the Compiler
and IIRC Diego has called for some kernel level Exception design.
There should be a family of CompilerError exceptions, (as well as
CollectionError, FileError, etc). The default handler for 
CompilerSyntaxError
should be the one to open the syntax error morph.

In that event, more stylish and intentful code might read as,

[Compiler evaluate: 'xlerb ; frobnozz ;;;']
	on: CompilerSyntaxError
	do: [<what you will in this particular context.>]

;-}>

PS Stephane, I would strongly urge the deprecation of the #ifError: 
protocol
as part of KCP. I still count 35 senders of this very questionable 
selector.

On Wednesday, May 21, 2003, at 10:40 AM, Derek Brans wrote:

> How about the usual error handling:
>
> [x := Compiler evaluate: 'blah blah'] ifError: [do something else]
>
>
> Derek Brans
> Nerd on a Wire
> Web design that's anything but square
> http://www.nerdonawire.com
> phone: 604.874.6463
> mailto: brans at nerdonawire.com
>
> ----- Original Message -----
> From: "Vladimir Janousek" <janousek at fit.vutbr.cz>
> To: "The general-purpose Squeak developers list"
> <squeak-dev at lists.squeakfoundation.org>
> Sent: Wednesday, May 21, 2003 10:32 AM
> Subject: [Q] Compiler evaluate: question
>
>
>> Hello Squeakers,
>>
>> I'd like to know some good way how to handle syntax error quietly in
>>
>>     x := Compiler evaluate: 'blah blah'.
>>
>> Unfortunately it seems that it does not raise any kind of exception.
>>
>> Thanks in advance,
>>
>> Vladimir
>>
>>
>>
>>
>>
>>
>
>



More information about the Squeak-dev mailing list