unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Chris Vine <vine35792468@gmail.com>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-user@gnu.org, guile-devel@gnu.org
Subject: Re: GNU Guile 2.9.5 Released [beta]
Date: Mon, 6 Jan 2020 23:14:19 +0000	[thread overview]
Message-ID: <20200106231419.7fd821d8a60f0ef400f7ffe1@gmail.com> (raw)
In-Reply-To: <87eewcs4r0.fsf@pobox.com>

On Mon, 06 Jan 2020 21:34:59 +0100
Andy Wingo <wingo@pobox.com> wrote:
> On Mon 06 Jan 2020 00:26, Chris Vine <vine35792468@gmail.com> writes:
> > I have a 'try' macro which adopts the approach that if an exception
> > arises, the macro unwinds from the dynamic environment of the code
> > where the exception arose to the dynamic environment of the call to
> > 'try', evaluates the cond clauses in that environment, and then if no
> > cond clause matches re-raises the exception in that environment with
> > 'raise' (rather than 'raise-continuable').  In other words, it does
> > stack unwinding in the same way as exception implementations in almost
> > all other mainstream languages which use exceptions.  It would be
> > trivial to implement this with guile-3.0's with-exception-handler with
> > its unwind? argument set to true.
> 
> I am not sure this really matches with this use case:
> 
>   (define (call-with-backtrace thunk)
>     (call/ec
>      (lambda (ret)
>        (with-exception-handler
>          (lambda (exn)
>            (show-backtrace exn) ;; placeholder
>            (ret))
>          thunk))))
> 
>   (define (false-on-file-errors thunk)
>     (call/ec
>      (lambda (ret)
>        (with-exception-handler
>          (lambda (exn)
>            (if (file-error? exn)
>                (ret #f)
>                (raise-continuable exn)))
>          thunk))))
>                
>   (define (foo f)
>     (call-with-backtrace
>      (lambda ()
>        (false-on-file-errors f))))
>          
>          
> If there's an error while invoking `f' that's not a file error, you want
> to have remained in the context of the error so you can show a full
> backtrace.  To my mind this is central to the exception handler design.
> So far so good I think.
> 
> If I change the implementation of `false-on-file-errors' to be:
> 
>   (define (false-on-file-errors thunk)
>     (guard (exn ((file-error? exn) #f))
>       (thunk)))
> 
> I think this change should preserve the not-unwinding environment that
> `call-with-backtrace' expects.

Good point.  My approach does provide the programmer with less conveyed
stack information after the re-raise of an unhandled exception,
requiring more manual intervention to recover the information when
debugging the exception.

Before you suggested it I had not previously considered your proposal.
It may turn out to be the optimum solution, but I wonder if it would
surprise the programmer to have the cond conditionals evaluated in a
different dynamic environment from the one in which the cond
consequential is evaluated where there is a conditional which is true.
But I am not sure if that is of any importance.

Chris



  reply	other threads:[~2020-01-06 23:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-22 15:22 GNU Guile 2.9.5 Released [beta] Andy Wingo
2019-11-22 16:01 ` tomas
2019-12-01 20:41 ` Chris Vine
2020-01-05 20:15   ` Andy Wingo
2020-01-05 23:26     ` Chris Vine
2020-01-06 20:34       ` Andy Wingo
2020-01-06 23:14         ` Chris Vine [this message]
2020-01-07 21:53           ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200106231419.7fd821d8a60f0ef400f7ffe1@gmail.com \
    --to=vine35792468@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=guile-user@gnu.org \
    --cc=wingo@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).