[Cuis-dev] [Ann] Refinements to Exception handling

Juan Vuletich juan at jvuletich.org
Mon Oct 14 03:54:22 PDT 2019


Hi Folks,

On 10/13/2019 5:12 PM, Andres Valloud via Cuis-dev wrote:
> The conversation that led to these changes went more or less like 
> this... first, I noted that exception handlers that look like this:
>
>     [:ex | ^5]
>
> are asking for trouble, because:
>
> a) effectively, nobody is looking at how the exception handling 
> mechanism is implemented, so doing non-local return like that curtails 
> the private implementation of exception handling,
>
> b) that kind of behavior is what the messages #return, #resume, #pass, 
> #outer, etc are there for,
>
> c) when you need to debug why exceptions are behaving a certain way, 
> the above exception handlers make debugging impossible because now 
> there's no place to put a breakpoint (e.g. in #return, #resume, #pass, 
> #outer, etc, which can be redefined for the purpose at hand in the 
> single exception of interest), and finally,
>
> d) it's possible to distort the exception handling mechanism behavior 
> with non-local returns.
>
>
> The vast majority of the time, I see exception handlers with non-local 
> returns as very close to expressions such as these:
>
>     #(1 2 3) asSortedCollection: [:x :y | ^x < y]
>
> where the behavior you get is not what you expected, even though the 
> code is doing exactly what was requested.  See attached for an actual 
> example of what I mean.  To run the code, do these and see what happens.
>
>     ExceptionExample new breakingStuff
>     ExceptionExample new workingStuff
>
> To me, generally speaking, these considerations push the scales 
> against the apparent convenience of having exception handlers do a 
> non-local return.  I do not want to have to debug that kind of 
> convenience under time pressure.  I do not even want to have to change 
> code that uses such convenience, because it's going to be more 
> difficult than otherwise.
>
>
> So Juan heard this and pointed out the reasoning is lovely but it's 
> not that helpful because the system is doing nothing to make users 
> aware of these facts.  He suggested the system should complain 
> instead.  Thus we (although he says mostly I) wrote code that detects 
> non-local return and complains.  I believe that code was integrated 
> recently (this bit, he did on his own LOL).
>
> Andres.
>

Thanks Andrés for the clarifications. It happened exactly as you describe.

Additional comments in answers to other messages in this thread.

Thanks,

-- 
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich



More information about the Cuis-dev mailing list