[squeak-dev] Slightly incorrect implementation of #resignalAs: ??

mail at jaromir.net mail at jaromir.net
Sat Jan 29 15:45:12 UTC 2022


Hi all,

I think Squeak's implementation of #resignalAs: is not following the ANSI specification precisely. Currently it reads:

resignalAs: replacementException

	signalContext resumeEvaluating: [replacementException signal]

ANSI says:
"
The active exception action is aborted and the exception environment *and the evaluation context*
are restored to the same states that were in effect when the receiver was originally signaled.
This message (i.e. resignalAs:) causes the replacementException to be treated as if it had been originally
signaled instead of the receiver.
"

This is very similar to #retry (or #retryUsing:) specification so I'd suggest the following implementation:

resignalAs: replacementException

	signalContext restartWithNewReceiver: replacementException

The current implementation leads to building the new resignaled contexts on top of the previous signal contexts (and the resignalAs context itself) instead of simply *restarting* the previous signal context with the replacement exception as the new receiver. In my opinion the suggested implementation precisely follows the ANSI specification, and is consistent with current #retry and #retryUsing: implementation - compare:

retryUsing: alternativeBlock
	"Abort an exception handler and evaluate a new block in place of the handler's protected block."

	handlerContext restartWithNewReceiver: alternativeBlock

Other dialects: Pharo and Cuis copied Squeak's but VW implemented resignalAs: to comply with ANSI precisely.

One consideration: the current implementation allows "exception resignalAs: Error", i.e. allows Exception class as an argument but ANSI's version requires "exception resignalAs: Error new". All senders (there are just a few) in the base image seem use "Error new" anyway.

My arguments for are: consistency, readability and less complexity (especially while debugging)

What do you think? Inbox it?

best,
~~~
^[^    Jaromir

Sent from Squeak Inbox Talk


More information about the Squeak-dev mailing list