From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH 1/2] srfi-34: Replace the 'raise' core binding. Date: Tue, 26 Nov 2019 14:09:44 +0100 Message-ID: <87y2w26axz.fsf@gnu.org> References: <20191125164555.15124-1-ludo@gnu.org> <20191125164555.15124-2-ludo@gnu.org> <877e3nt0dm.fsf@igalia.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="251523"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: guile-devel@gnu.org To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Nov 26 14:09:55 2019 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iZabK-0013Dj-LV for guile-devel@m.gmane.org; Tue, 26 Nov 2019 14:09:54 +0100 Original-Received: from localhost ([::1]:54644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZabI-0004nI-TI for guile-devel@m.gmane.org; Tue, 26 Nov 2019 08:09:52 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36062) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZabE-0004my-Cu for guile-devel@gnu.org; Tue, 26 Nov 2019 08:09:49 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:56307) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iZabD-0008B5-OX; Tue, 26 Nov 2019 08:09:47 -0500 Original-Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=47034 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1iZabD-0002GN-8T; Tue, 26 Nov 2019 08:09:47 -0500 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 6 Frimaire an 228 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu In-Reply-To: <877e3nt0dm.fsf@igalia.com> (Andy Wingo's message of "Tue, 26 Nov 2019 11:09:25 +0100") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:20172 Archived-At: Andy Wingo skribis: > On Mon 25 Nov 2019 17:45, Ludovic Court=C3=A8s 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 >>=20=20 >> -;; 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: >>=20=20 >> (define-module (srfi srfi-34) >> - #:re-export (with-exception-handler >> - (raise-exception . raise)) >> + #:re-export (with-exception-handler) >> + #:replace (raise) >> #:export-syntax (guard)) >>=20=20 >> (cond-expand-provide (current-module) '(srfi-34)) >>=20=20 >> +(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. =E2=80=98raise=E2=80=99 takes exactly one argument, whereas =E2=80=98r= aise-exception=E2=80=99 takes an additional keyword argument. We could ignore #2, though it=E2=80=99s not great, but I=E2=80=99m 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=E2=80=99s important from a usability viewpoint. Thanks! Ludo=E2=80=99.