unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Jean Abou Samra <jean@abou-samra.fr>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: christopher.lck@gmail.com, 58109@debbugs.gnu.org, guile-devel@gnu.org
Subject: Re: bug#58109: simple-format vs (ice-9 format) bug in 3.0.7?
Date: Sat, 1 Oct 2022 16:14:17 +0200	[thread overview]
Message-ID: <cc81cf8f-86f5-f350-cab5-e090ade1cbc7@abou-samra.fr> (raw)
In-Reply-To: <87ill3fyrh.fsf@gnu.org>



Le 01/10/2022 à 15:40, Ludovic Courtès a écrit :
> Hi,
>
> Jean Abou Samra <jean@abou-samra.fr> skribis:
>
>> Uh, at the end of module/ice-9/format.scm, there is
>>
>> ;; Thanks to Shuji Narazaki
>> (module-set! the-root-module 'format format)
>>
>> which dates back to
>>
>> commit 14469b7c69feb0f2c5b8a093f19fe2a548b31c5b
>> Author: Greg J. Badros <gjb@cs.washington.edu>
>> Date:   Thu Jan 20 20:58:30 2000 +0000
> [...]
>
>> This probably predates #:replace and could be removed now, right?
> Yes, it could be removed, but probably not before the 4.0 series.
>
> The ‘-Wformat’ warning introduced sometime in the 2.0 or 2.2 series
> prepared for that removal by warning about simple-format/format
> mismatches, but there’s probably still code out there that assumes
> ‘format’ is the full-blown ‘format’, even when (ice-9 format) is not
> explicitly imported.



OK, understood. How about adding comments and documentation?

diff --git a/doc/ref/misc-modules.texi b/doc/ref/misc-modules.texi
index 6c899a905..2c00ed859 100644
--- a/doc/ref/misc-modules.texi
+++ b/doc/ref/misc-modules.texi
@@ -1122,6 +1122,13 @@ you try to use one of them.  The reason for two 
versions is that the
  full @code{format} is fairly large and requires some time to load.
  @code{simple-format} is often adequate too.

+Beware that when @code{(ice-9 format)} is loaded, it replaces the
+binding for @code{format} on the toplevel.  If your module loads
+another module that loads @code{(ice-9 format)}, then your module
+will see the @code{format} function from @code{(ice-9 format)},
+even if it does not itself import @code{(ice-9 format)}.  This is
+legacy behavior and may be removed in a future Guile version.
+

  @node File Tree Walk
  @section File Tree Walk
diff --git a/module/ice-9/format.scm b/module/ice-9/format.scm
index ee7cba910..026fd9b54 100644
--- a/module/ice-9/format.scm
+++ b/module/ice-9/format.scm
@@ -32,6 +32,8 @@
  (define-module (ice-9 format)
    #:autoload (ice-9 pretty-print) (pretty-print truncated-print)
    #:autoload (ice-9 i18n)         (%global-locale number->locale-string)
+  ;; Actually replaces the global format as soon as loaded; see the end
+  ;; of this file.
    #:replace (format))

  (define format:version "3.0")
@@ -83,7 +85,7 @@
    ;; format's user error handler

    (define (format-error . args)       ; never returns!
-    (with-throw-handler #t
+    (with-throw-handler #t
        (lambda ()
          (let ((port (current-error-port)))
            (unless (zero? %arg-pos)
@@ -1560,5 +1562,10 @@
            (close-port port)
            str)))))

-;; Thanks to Shuji Narazaki
+;; Set the format variable in the root module.  This is legacy and
+;; no longer necessary.  It means that as soon as (ice-9 format) is
+;; loaded somewhere by some module, the predefined binding for format
+;; becomes the extended format function, even in modules where (ice-9 
format)
+;; isn't imported.  Because of this, removing this line should be done
+;; when a backwards compatibility break is allowed.
  (module-set! the-root-module 'format format)




Best,
Jean




  reply	other threads:[~2022-10-01 14:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-27 10:23 bug#58109: simple-format vs (ice-9 format) bug in 3.0.7? Christopher Lam
2022-09-27 10:35 ` Jean Abou Samra
2022-09-27 10:38   ` Jean Abou Samra
2022-10-01 13:40     ` bug#58109: " Ludovic Courtès
2022-10-01 14:14       ` Jean Abou Samra [this message]
2022-10-12 20:50         ` Ludovic Courtès

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=cc81cf8f-86f5-f350-cab5-e090ade1cbc7@abou-samra.fr \
    --to=jean@abou-samra.fr \
    --cc=58109@debbugs.gnu.org \
    --cc=christopher.lck@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=ludo@gnu.org \
    /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).