[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/2] srfi-34: Replace the 'raise' core binding.
From: |
Ludovic Courtès |
Subject: |
Re: [PATCH 1/2] srfi-34: Replace the 'raise' core binding. |
Date: |
Tue, 26 Nov 2019 14:09:44 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
Andy Wingo <address@hidden> skribis:
> On Mon 25 Nov 2019 17:45, Ludovic Courtès <address@hidden> writes:
>
>> In Guile 2.x, (srfi srfi-34) would already replace 'raise'. Replacing
>> avoids a run-time warning about the core binding being overridden.
>>
>> * module/srfi/srfi-34.scm (raise): New variable.
>> Mark it as #:replace instead of #:re-export.
>> ---
>> module/srfi/srfi-34.scm | 10 +++++++---
>> 1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/module/srfi/srfi-34.scm b/module/srfi/srfi-34.scm
>> index 0e7ad995d..255bfecb9 100644
>> --- a/module/srfi/srfi-34.scm
>> +++ b/module/srfi/srfi-34.scm
>> @@ -1,6 +1,6 @@
>> ;;; srfi-34.scm --- Exception handling for programs
>>
>> -;; Copyright (C) 2003, 2006, 2008, 2010 Free Software Foundation, Inc.
>> +;; Copyright (C) 2003, 2006, 2008, 2010, 2019 Free Software Foundation, Inc.
>> ;;
>> ;; This library is free software; you can redistribute it and/or
>> ;; modify it under the terms of the GNU Lesser General Public
>> @@ -27,12 +27,16 @@
>> ;;; Code:
>>
>> (define-module (srfi srfi-34)
>> - #:re-export (with-exception-handler
>> - (raise-exception . raise))
>> + #:re-export (with-exception-handler)
>> + #:replace (raise)
>> #:export-syntax (guard))
>>
>> (cond-expand-provide (current-module) '(srfi-34))
>>
>> +(define (raise exn)
>> + "Raise the given exception, invoking the current exception handler on
>> EXN."
>> + (raise-exception exn))
>
> LGTM but it is better to re-export if possible. The reason is that
> right now the compiler recognizes "throw" and "error" as not falling
> through, and this is good for a number of reasons; it would be nice to
> extend this to raise-exception. We should make it possible to re-export
> and replace at the same time, IMO.
AFAICS there are two blockers:
1. We cannot replace & re-export at the same time.
2. ‘raise’ takes exactly one argument, whereas ‘raise-exception’ takes
an additional keyword argument.
We could ignore #2, though it’s not great, but I’m not sure how to fix #1.
Perhaps also we should provide a mechanism similar to GCC attributes to
mark a procedure as throwing, so that the compiler can DTRT?
Anyway, in the meantime, should we go ahead and apply this patch? I
think it’s important from a usability viewpoint.
Thanks!
Ludo’.