Exception handling in VAST and other Smalltalks

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

Exception handling in VAST and other Smalltalks

Postby davidg » Mon Nov 19, 2007 1:08 am

This is related to my other reply in the PDF reader thread and to portability of code between Smalltalks.

In VAST there are some differences how Exceptions are being handled with regard to other Smalltalks.

For example:

[ 1/ 0 ] on: Exception do: [:ex | self halt]

In VAST the ZeroDivide error will pop-up if you evaluate the code above. But as in all other Smalltalks, the exception handler should be evaluated.

Also, there is another issue. In Dolphin and in VisualWorks if I write:

[ 1/ 0 ] on: Error do: [:ex | ]

has the same effect as if I would write the following in VAST:

[ 1 / 0] on: Error do: [:ex | ex exitWith: nil].

I would be nice if the default action (in case exception is not resumable) would be the same as it is in VisualWorks and Dolphin (I think Squeak is the same), so that one does not need to send #exitWith: ...

So, for this, I have sent the following changes to support by e-mail almost a year back, but none of these changes were integrated into the latest version.

1. Exception class>>#exceptionalEvent should be as follows:
exceptionalEvent == nil
[self == Exception
ifTrue: [exceptionalEvent := ExAll]
[self == Error
ifTrue: [exceptionalEvent := ExError]
[(exceptionalEvent := ExceptionalEvent basicNew)
parent: self superclass exceptionalEvent;
description: name , ' Exception';
defaultHandler: self defaultHandlerBlock;
resumable: self isResumable "$NON-NLS$"]]].

After integrating this code you also have to reinitialize exception event object by evaluating:

Exception reset.

2. The following change to method Signal>>#evaluate: would seem logical regarding error handling compatibility and I think would not break anything:

evaluate: aBlock
"Evaluate aBlock. Return if the reciever is signaled. Resume
the reciever if the execution of aBlock falls off the end."

self signalBlock: [^self].
self resumable
ifTrue: [self resumeWith: (aBlock value: self)]
ifFalse: [self exitWith: (aBlock value: self)]

This base changes would make VAST compatible with Dolphin and VW. Now, would this break some existing code of another customer? That I don't know.
Posts: 6
Joined: Mon Dec 25, 2006 5:42 am

Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest