[Cuis-dev] Exception handler blocks with non-local returns

Andres Valloud ten at smallinteger.com
Mon Oct 14 00:04:09 PDT 2019


On 10/13/19 21:36, Phil B wrote:
> Andres,
> 
> On Sun, Oct 13, 2019 at 10:51 PM Andres Valloud via Cuis-dev 
> <cuis-dev at lists.cuis.st <mailto:cuis-dev at lists.cuis.st>> wrote:
> 
>     Do we even agree this is a problem?
> 
> I'd say there's a second question: If so, what do we do about it?

Provided we agree there's a problem, we can consider that.  Part of what 
I'm trying to do here is to fully characterize the problem before coming 
up with solutions.  Otherwise, there is a risk that we will engage in 
so-called 'solutioning' (i.e. a beauty contest between solutions), 
instead of solving the problem.

> I would agree it's a problem and that it's a question of how to handle 
> it.  I'm in favor of at least voluntarily minimizing the use of 
> non-local returns just to ensure expected debugger behavior regardless 
> of whether or not it's technically 'legal' and/or we effectively forbid it.

Ok, but let's hear from others before deciding on a path forward.

> One bit of feedback on this approach related to the last time we forbid 
> something this way: I still absolutely *hate* the exceptions for 
> shadowing variable names.  I find the mechanism annoying for something 
> that is a non-problem to me.  Others may feel that way about raising 
> exceptions for this issue.  I would much prefer that we handle issues 
> like these with some sort of opt-in linting/logging mechanism than 
> mandatory policy enforced by exceptions.

I know nothing of this, I have no opinion.

>     d) it's possible to distort the exception handling mechanism behavior
>     with non-local returns.
> 
> This one concerns me because we effectively have what appears to be a 
> 'legal' (in the sense that blocks can do it) end-run around the 
> exception mechanism.  Are there any examples of existing core code / 
> packages with subtle bugs because of this?

I do not recall any specific instance of an actual bug because of this 
issue at this time.  I have a general recollection of seeing, many 
times, code that read along the lines of

	[:ex | ^5]

when it really meant

	[:ex | ex return: 5]

and the problem with it is that it's not debugging friendly.  That is, 
it's not that [:ex | ^5] itself caused a bug, but I was debugging around 
that and the non-local return made life harder than necessary.

> Finally, does any literature (Blue Book, ANSI, previous discussion(s)... 
> whatever) specifically discuss do's/don'ts re: exception blocks or is it 
> just an ambiguous issue that was never delved into?  If anything does 
> exist, shouldn't we also consider it regarding how to proceed?

Sure, we can look into that.

Andres.


More information about the Cuis-dev mailing list