unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Maxime Devos via "Bug reports for GUILE, GNU's Ubiquitous Extension Language" <bug-guile@gnu.org>
To: Attila Lendvai <attila@lendvai.name>
Cc: "46009@debbugs.gnu.org" <46009@debbugs.gnu.org>,
	Christopher Baines <mail@cbaines.net>,
	"guile-devel@gnu.org" <guile-devel@gnu.org>
Subject: bug#46009: exception from inside false-if-exception?
Date: Mon, 17 Jun 2024 22:50:54 +0200	[thread overview]
Message-ID: <20240617225055.ckqu2C0045M5ED401kquFP__25361.5466224559$1718657619$gmane$org@laurent.telenet-ops.be> (raw)
In-Reply-To: <cKnzun5yW-Q_THEaSos_kxjOFWnNhitKD9PhgZpRW6mbC8NQmCFVnEtUsi8KtkaBBGoqpqpOIBT7U2FRRmk4CsZ2nFuaRdxxNcvHg9ErUt4=@lendvai.name>

[-- Attachment #1: Type: text/plain, Size: 2846 bytes --]

>it's a tangential, but namely, when #:unwind #t then the handler in a w-e-h returns from the w-e-h block, but with #:unwind #f it tries to return to the RAISE that raised the condition. i.e. a lousy little keyword arg (usually a page down) fundamentally changes the behavior of w-e-h. yet another surprise that violated my expectations regarding APIs.

What is lousy and expectation-violating about a keyword argument doing what it name describes?

If you have unwinded, it’s too late to return return from the raise (unless the implementation is doing delimited continuations shenanigans, which maybe you had in mind?), which explains the behaviour for #:unwind #true.

If you are _not_ unwinding, then the handler can’t be run less deep in the call stack (i.e. “from the w-e-h block”), because to get less deep in the call stack, you need to unwind.

So, there is a direct relation between unwinding/no unwinding, and returning from “the w-e-h block”/”raise(-continuable)”.

If you don’t want Guile to unwind, then maybe don’t ask it to unwind. (Previous sentence N/A if you had above-mentioned delimited continuation shenanigans in mind.)

That said, I would prefer it to be named something like [#:handler-context 'raise]/[#:handler-context 'guard] instead of #:unwind? #false/#true, since ‘unwind’ refers to the implementation instead of the semantics(*). That would reduce the need of roughly knowing how it is implemented (I have a rough idea for an alternate implementation where some unwinding always happens, and the handler is run in the dynamic environment of the ‘guard/with-exception-handler’ instead of the ‘raise’(*), and if raise-continuable is used and the handler returns something, then _re_winding happens via delimited continuations.).

(*)I think this is how it’s supposed to work (?) (including in R6RS), but Guile doesn’t do this. (Except for interactions with dynamic-wind, which might now be incorrect in the case of raise-continuable, but really you shouldn’t be using dynamic-wind in the first place.)

>anyway, i've attached a patch that clarifies what's happening for anyone who stumbles upon this; i.e. be clearer that (?) a backtrace is printed due to reaching a continuation barrier.

Wait where did this happen? You say what’s happening, but you don’t seem to be referring to false-if-exception stuff, and you didn’t mention continuation barriers earlier.

>if someone wants to investigate further, then i'm also attaching a new version of my test.scm that behaves in an unexpected way on 3.0.9, but not on HEAD (more specifically on guile-next in guix, which is a rather recent commit).

It would be helpful to include in test.scm what the expected output would be and what unexpected output is encountered.

Best regards,
Maxime Devos.


[-- Attachment #2: Type: text/html, Size: 5403 bytes --]

  parent reply	other threads:[~2024-06-17 20:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <EFwqPXniEWt-XKJDljH6WU5gdrd9NZ7ljHXRhU7vZJBPk9kPpy7K7OEDLX0SjGkZMM38ugEZMuyfMvsD7I5fCIqvwgRaBPZyV8tOpobPyUU=@lendvai.name>
2024-04-29 14:13 ` bug#46009: exception from inside false-if-exception? Maxime Devos
     [not found] ` <87le4wz1s9.fsf@cbaines.net>
     [not found]   ` <KK9h-weV6TT-z77G7nv8HpFWSdI52KcMByBuvPWFDgI2m6yVcjt_xvzPVrYiUrfgBbiycH3UYqw-kXDgd6R5fhMNTkMBK-1rPkzDkK6oMl4=@lendvai.name>
     [not found]     ` <20240506205840.Kuyd2C00E17cfcj01uygoD@xavier.telenet-ops.be>
2024-06-12 16:32       ` Attila Lendvai
     [not found]       ` <RpVsWsoGpFfNnEgFkKVrSOPG__6WbxYVUBWsiPaRB1qR9X3yTenQxN97VRRpCVokam6oNj9BEMSbSgcR2IFGm5UHC15rbaQk6KgrOPrW2Dc=@lendvai.name>
2024-06-17 19:57         ` Attila Lendvai
     [not found]         ` <cKnzun5yW-Q_THEaSos_kxjOFWnNhitKD9PhgZpRW6mbC8NQmCFVnEtUsi8KtkaBBGoqpqpOIBT7U2FRRmk4CsZ2nFuaRdxxNcvHg9ErUt4=@lendvai.name>
2024-06-17 20:50           ` Maxime Devos via Bug reports for GUILE, GNU's Ubiquitous Extension Language [this message]
     [not found]           ` <20240617225055.ckqu2C0045M5ED401kquFP@laurent.telenet-ops.be>
2024-06-17 21:45             ` Attila Lendvai
     [not found]             ` <ZoTxVfkW_yf_11HX8eZqRH2bS1CpxEVIk6Rf8DFiu-Z1TbzqPCrjk7lEXgi9GQTNwt3Ku6nIjzgFFkP54P-vk-fvaRGpxvU43hgikCy6Kfc=@lendvai.name>
2024-06-19 16:51               ` Maxime Devos via Bug reports for GUILE, GNU's Ubiquitous Extension Language
     [not found]               ` <20240619185059.dUqy2C00M0K6dk406UqzfD@michel.telenet-ops.be>
2024-06-19 18:58                 ` Attila Lendvai
     [not found]                 ` <ud0zXDf9dLoy7OTaH1cMKMrfjDXwTDp4yOO8d1IAEeh8LM8tgDZA2D49AFhWtcIAOPlX9pEWcjbrA-Q1YQ-EqRZBtxO6xC2Gu1KQRB1YDC8=@lendvai.name>
2024-06-19 22:03                   ` Maxime Devos via Bug reports for GUILE, GNU's Ubiquitous Extension Language

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='20240617225055.ckqu2C0045M5ED401kquFP__25361.5466224559$1718657619$gmane$org@laurent.telenet-ops.be' \
    --to=bug-guile@gnu.org \
    --cc=46009@debbugs.gnu.org \
    --cc=attila@lendvai.name \
    --cc=guile-devel@gnu.org \
    --cc=mail@cbaines.net \
    --cc=maximedevos@telenet.be \
    /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).