unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH 0/2] Silence run-time warnings for SRFI-3[45]
@ 2019-11-25 16:45 Ludovic Courtès
  2019-11-25 16:45 ` [PATCH 1/2] srfi-34: Replace the 'raise' core binding Ludovic Courtès
  2019-11-25 16:45 ` [PATCH 2/2] srfi-35: Replace '&error' Ludovic Courtès
  0 siblings, 2 replies; 7+ messages in thread
From: Ludovic Courtès @ 2019-11-25 16:45 UTC (permalink / raw)
  To: guile-devel; +Cc: wingo, Ludovic Courtès

Hi!

As it stands, Guix on Guile 2.9.5 produces lots of warnings:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix build libreoffice -nd
WARNING: (guix build utils): imported module (srfi srfi-35) overrides core binding `&error'
WARNING: (guix utils): imported module (srfi srfi-35) overrides core binding `&error'
WARNING: (guix serialization): imported module (srfi srfi-35) overrides core binding `&error'
WARNING: (guix base32): imported module (srfi srfi-35) overrides core binding `&error'
WARNING: (guix store): imported module (srfi srfi-35) overrides core binding `&error'
WARNING: (guix derivations): imported module (srfi srfi-35) overrides core binding `&error'
WARNING: (guix gexp): imported module (srfi srfi-35) overrides core binding `&error'
WARNING: (guix packages): imported module (srfi srfi-35) overrides core binding `&error'
WARNING: (guix modules): imported module (srfi srfi-35) overrides core binding `&error'
WARNING: (guix profiles): imported module (srfi srfi-35) overrides core binding `&error'
WARNING: (guix build gremlin): imported module (srfi srfi-35) overrides core binding `&error'
/gnu/store/lyyllcqa1hq7k3zrv03m2h3xz4a6qawx-libreoffice-6.3.3.2.drv
--8<---------------cut here---------------end--------------->8---

These patches address that.  The first one restores #:replace for
srfi-34 (as was the case in Guile 2.x), and the second one adds
#:replace for srfi-35.

Let me know what you think!

Overall, I think we should be cautious with run-time warnings
because they’re hard to turn off and there’s nothing the user
(as in: the Guix user) can do about it.

Ludo’.

Ludovic Courtès (2):
  srfi-34: Replace the 'raise' core binding.
  srfi-35: Replace '&error'.

 module/srfi/srfi-34.scm | 10 +++++++---
 module/srfi/srfi-35.scm |  6 ++++--
 2 files changed, 11 insertions(+), 5 deletions(-)

-- 
2.24.0




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] srfi-34: Replace the 'raise' core binding.
  2019-11-25 16:45 [PATCH 0/2] Silence run-time warnings for SRFI-3[45] Ludovic Courtès
@ 2019-11-25 16:45 ` Ludovic Courtès
  2019-11-26 10:09   ` Andy Wingo
  2019-11-25 16:45 ` [PATCH 2/2] srfi-35: Replace '&error' Ludovic Courtès
  1 sibling, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2019-11-25 16:45 UTC (permalink / raw)
  To: guile-devel; +Cc: wingo, Ludovic Courtès

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))
+
 (define-syntax guard
   (syntax-rules (else)
     "Syntax: (guard (<var> <clause1> <clause2> ...) <body>)
-- 
2.24.0




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] srfi-35: Replace '&error'.
  2019-11-25 16:45 [PATCH 0/2] Silence run-time warnings for SRFI-3[45] Ludovic Courtès
  2019-11-25 16:45 ` [PATCH 1/2] srfi-34: Replace the 'raise' core binding Ludovic Courtès
@ 2019-11-25 16:45 ` Ludovic Courtès
  2019-11-26 10:10   ` Andy Wingo
  1 sibling, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2019-11-25 16:45 UTC (permalink / raw)
  To: guile-devel; +Cc: wingo, Ludovic Courtès

This ensures core binding '&error' is silently replaced by the SRFI-35
variant.

* module/srfi/srfi-35.scm (srfi:&error): New variable.  Use it to
 #:replace '&error'.
---
 module/srfi/srfi-35.scm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/module/srfi/srfi-35.scm b/module/srfi/srfi-35.scm
index d1549f9d4..efa1566bf 100644
--- a/module/srfi/srfi-35.scm
+++ b/module/srfi/srfi-35.scm
@@ -1,6 +1,6 @@
 ;;; srfi-35.scm --- Conditions                 -*- coding: utf-8 -*-
 
-;; Copyright (C) 2007-2011, 2017 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2011, 2017, 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
@@ -39,8 +39,8 @@
                (exception-message . condition-message)
                (&error . &serious)
                (error? . serious-condition?)
-               (&external-error . &error)
                (external-error? . error?))
+  #:replace ((srfi:&error . &error))
   #:export (make-condition
             define-condition-type
             condition-has-type?
@@ -139,3 +139,5 @@ by C."
     ((_ (type field ...) ...)
      (make-compound-condition (condition-instantiation type () field ...)
                               ...))))
+
+(define srfi:&error &external-error)
-- 
2.24.0




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] srfi-34: Replace the 'raise' core binding.
  2019-11-25 16:45 ` [PATCH 1/2] srfi-34: Replace the 'raise' core binding Ludovic Courtès
@ 2019-11-26 10:09   ` Andy Wingo
  2019-11-26 13:09     ` Ludovic Courtès
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Wingo @ 2019-11-26 10:09 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guile-devel

On Mon 25 Nov 2019 17:45, Ludovic Courtès <ludo@gnu.org> 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.

Andy



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] srfi-35: Replace '&error'.
  2019-11-25 16:45 ` [PATCH 2/2] srfi-35: Replace '&error' Ludovic Courtès
@ 2019-11-26 10:10   ` Andy Wingo
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Wingo @ 2019-11-26 10:10 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guile-devel

On Mon 25 Nov 2019 17:45, Ludovic Courtès <ludo@gnu.org> writes:

> This ensures core binding '&error' is silently replaced by the SRFI-35
> variant.

Again LGTM but it would be nicest to really re-export the binding
instead of making a new definition :)

Andy



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] srfi-34: Replace the 'raise' core binding.
  2019-11-26 10:09   ` Andy Wingo
@ 2019-11-26 13:09     ` Ludovic Courtès
  2019-11-29 11:00       ` Andy Wingo
  0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2019-11-26 13:09 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guile-devel

Andy Wingo <wingo@igalia.com> skribis:

> On Mon 25 Nov 2019 17:45, Ludovic Courtès <ludo@gnu.org> 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’.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] srfi-34: Replace the 'raise' core binding.
  2019-11-26 13:09     ` Ludovic Courtès
@ 2019-11-29 11:00       ` Andy Wingo
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Wingo @ 2019-11-29 11:00 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guile-devel

On Tue 26 Nov 2019 14:09, Ludovic Courtès <ludo@gnu.org> writes:

> AFAICS there are two blockers:
>
>   1. We cannot replace & re-export at the same time.

Following discussion on IRC, this is fixed now, with
#:re-export-and-replace.  Would be nice if #:re-export could know
whether a binding is local or re-exported and DTRT but that isn't the
case currently.

>   2. ‘raise’ takes exactly one argument, whereas ‘raise-exception’ takes
>      an additional keyword argument.

I think ignoring this one is fine FWIW.

> Perhaps also we should provide a mechanism similar to GCC attributes to
> mark a procedure as throwing, so that the compiler can DTRT?

An interesting option :)  FWIW the compiler has to also know how to call
the callee...  Something to think about.

Cheers,

Andy



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-11-29 11:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-25 16:45 [PATCH 0/2] Silence run-time warnings for SRFI-3[45] Ludovic Courtès
2019-11-25 16:45 ` [PATCH 1/2] srfi-34: Replace the 'raise' core binding Ludovic Courtès
2019-11-26 10:09   ` Andy Wingo
2019-11-26 13:09     ` Ludovic Courtès
2019-11-29 11:00       ` Andy Wingo
2019-11-25 16:45 ` [PATCH 2/2] srfi-35: Replace '&error' Ludovic Courtès
2019-11-26 10:10   ` Andy Wingo

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).