[darcs-devel] [patch1890] make scope of exception handler explicit (and 2 more)

Ganesh Sittampalam bugs at darcs.net
Mon Aug 26 17:11:30 UTC 2019


Ganesh Sittampalam <ganesh at earth.li> added the comment:

>> No idea what the author intended, but the brackets I introduced were
>> behaviour preserving.
> 
> My mistake. I never doubted that. I meant "extending the scope" as
> "relative to what I think was originally intended", not as "relative to
> what it currently does".

Oh, I see. I didn't really think about that as I was already deep into
yak-shaving by that point (aargh, test failing...why this useless error
message?...what the hell is the precedence here??). I just wanted to be
sure I wasn't changing anything unintentionally.

> If you prefer to keep the existing behavior instead of changing to to
> what I think was intended, that's okay. But then you should at least
> clean up the '>>' here by unfolding the two statements into separate
> actions of the do block.

OK, sent.

> (I would also appreciate a more thorough cleanup of the whole function
> but that may be out of scope for you (no pun intended).)

Yeah, sorry, don't feel motivated by that right now.

> Unfortunately we use this pattern quite a lot and I have stumbled over
> this exact same problem often enough in my refactors that I am nowadays
> quite sensitive to it. One way to avoid it is to factor the code we want
> to scope over into a local function. I also reject the unwritten law
> that 'catch' must be used infix. In fact, using parentheses is natural
> for prefix use, so this is another way to avoid the non-obvious scoping
> caused by the non-obvious precedence rule.
> 
> (The interaction with layout-sensitive do-notation is a case where infix
> operators are not a good substitute for dedicated syntax, much less
> programmable syntax a la scheme.)

Yeah. Any two of do, if-then-else and infix operators in close proximity
are often a recipe for confusion.

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/patch1890>
__________________________________


More information about the darcs-devel mailing list