Hi all!
I was just wondering why IllegalResumeAttempt is not an error. An IllegalResumeAttempt is signaled when you try to #resume from an exception that is not resumable.
In my opinion, this should pretty clearly be an Error. Just like "nil + 1", "#() at: 0", or "'hello' at: 1 put: $H", the programmer is trying to perform an illegal operation so the EHS notices this error. Why should "Error new resume" (pseudo, of course) not be an Error?
I could imagine that in ancient days, when nested exception handling did not yet work as flawlessly as today (thanks Jaromir and Nicolas for all the work on this field!), the original designers tried to prevent the case in which a second exception was handled on the stack. Nevertheless, this limitation does not exist any longer today. It would not even be a problem (although not a recommended pattern) to say something like:
[self error + 1] on: Error do: [:ex1 | [ex1 resume: 42] on: IllegalResumeAttempt do: [:ex2 | "Well, then return instead" ex1 return: 42] ].
So why don't we just go and make IllegalResumeAttempt an Error? Its defaultAction is already completely compatible.
Best, Christoph
Hi Christoph,
There's a funny method under IllegalResumeAttempt:
#readMe
"Never handle this exception!"
Author: The Fourth Estate, Inc., 1999
I can't see anything wrong with your example, the logic is clean so I'm very curious what more experienced people have to say :)
Christoph Thiede wrote
It would not even be a problem (although not a recommended pattern) to say something like:
[self error + 1] on: Error do: [:ex1 | [ex1 resume: 42] on: IllegalResumeAttempt do: [:ex2 | "Well, then return instead" ex1 return: 42] ].
best,
----- ^[^ Jaromir -- Sent from: http://forum.world.st/Squeak-Dev-f45488.html
Hi Jaromir, all,
ah, revisiting all the old discussions. :-)
The only reason I could imagine not defining IllegalResumeAttempt as a subclass of Error would be a situation where an "on: Error do:" handler is still active while evaluating the handlerBlock. But looking at Context>>#handleSignal:, this cannot happen, right?
And another question: When we define this as a subclass of Error, we could actually make it resumable, couldn't we? Thus, IllegalResumeAttempt>>resume would do the same as #resumeUnchecked:. :-)
If nobody objects, I will apply these changes soon.
Best, Christoph
--- Sent from Squeak Inbox Talk
On 2021-05-14T14:10:35-05:00, m@jaromir.net wrote:
Hi Christoph,
There's a funny method under IllegalResumeAttempt:
#readMe
"Never handle this exception!"
Author: The Fourth Estate, Inc., 1999
I can't see anything wrong with your example, the logic is clean so I'm very curious what more experienced people have to say :)
Christoph Thiede wrote
It would not even be a problem (although not a recommended pattern) to say something like:
[self error + 1] on: Error do: [:ex1 | [ex1 resume: 42] on: IllegalResumeAttempt do: [:ex2 | "Well, then return instead" ex1 return: 42] ].
best,
^[^ Jaromir
Sent from: http://forum.world.st/Squeak-Dev-f45488.html
squeak-dev@lists.squeakfoundation.org