Subject: bug#11293: closed (Re: bug#11293: format and simple-format confused after compiling)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 21 Apr 2012 23:32:03 +0000

Your bug report

#11293: format and simple-format confused after compiling

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
11293: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11293
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#11293: format and simple-format confused after compiling
From: [email-masked] (Ludovic Courtès)
To: Aleix Conchillo Flaqué <[email-masked]>
Cc: [email-masked]
Date: Sun, 22 Apr 2012 01:30:04 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi Aleix,

Aleix Conchillo Flaqué <[email-masked]> skribis:

> However, if I execute it a second time without modifying the file I get:
>
> my first message with a new line
> my first formattedBacktrace:
> In ice-9/boot-9.scm:
>  157: 7 [catch #t #<catch-closure 1aee9c0> ...]
> In unknown file:
>    ?: 6 [apply-smob/1 #<catch-closure 1aee9c0>]
> In ice-9/boot-9.scm:
>   63: 5 [call-with-prompt prompt0 ...]
> In ice-9/eval.scm:
>  407: 4 [eval # #]
> In ice-9/boot-9.scm:
> 2189: 3 [save-module-excursion #<procedure 1aed340 at
> ice-9/boot-9.scm:3724:3 ()>]
> 3731: 2 [#<procedure 1aed340 at ice-9/boot-9.scm:3724:3 ()>]
> In unknown file:
>    ?: 1 [load-compiled/vm
> "/home/aleix/.cache/guile/ccache/2.0-LE-8-2.0/home/aleix/src/guile/guile-cookbook/recipe-3/recipe-3.scm.go"]
>    ?: 0 [simple-format #t ...]
>
> ERROR: In procedure simple-format:
> ERROR: In procedure simple-format: FORMAT: Unsupported format option
> ~d - use (ice-9 format) instead

That’s because (ice-9 format) does this evil thing:

  (module-set! the-root-module 'format format)

In the first run, since the compiler uses (ice-9 format), the global
‘format’ binding pointed to the (ice-9 format) one.  However, in the
second run, the global ‘format’ binding pointed to ‘simple-format’,
hence the error.

Starting from Guile 2.0.5, the ‘format’ compiler warning reports such
problems:

  scheme@(guile-user)> (format #f "~d" 2)
  ;;; <stdin>:1769:0: warning: "~d": unsupported format option ~d, use (ice-9 format) instead

The fix is to explicitly import (ice-9 format) in your module.

Closing this bug, let us know if anything else is wrong!

Thanks,
Ludo’.

Subject: format and simple-format confused after compiling
From: Aleix Conchillo Flaqué <[email-masked]>
To: [email-masked]
Date: Fri, 20 Apr 2012 23:43:46 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

today I just got a weird issue (probably my fault). I'm trying to
write a very basic Guile cookbook for beginners, which is the ony
think I know in any case.

Anyway, I have this script:

#!/usr/bin/guile -s
!#

(simple-format #t "my first message with a new line~%")

(format #t "my first ~a message with a number ~d and a new line~%"
           "formatted" 1)

If you execute it for the first time (or after being edited) it
returns the right thing:

;;; note: source file /home/aleix/src/guile/guile-cookbook/recipe-3/recipe-3.scm
;;;       newer than compiled
/home/aleix/.cache/guile/ccache/2.0-LE-8-2.0/home/aleix/src/guile/guile-cookbook/recipe-3/recipe-3.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /home/aleix/src/guile/guile-cookbook/recipe-3/recipe-3.scm
;;; compiled /home/aleix/.cache/guile/ccache/2.0-LE-8-2.0/home/aleix/src/guile/guile-cookbook/recipe-3/recipe-3.scm.go
my first message with a new line
my first formatted message with a number 1 and a new line

However, if I execute it a second time without modifying the file I get:

my first message with a new line
my first formattedBacktrace:
In ice-9/boot-9.scm:
 157: 7 [catch #t #<catch-closure 1aee9c0> ...]
In unknown file:
   ?: 6 [apply-smob/1 #<catch-closure 1aee9c0>]
In ice-9/boot-9.scm:
  63: 5 [call-with-prompt prompt0 ...]
In ice-9/eval.scm:
 407: 4 [eval # #]
In ice-9/boot-9.scm:
2189: 3 [save-module-excursion #<procedure 1aed340 at
ice-9/boot-9.scm:3724:3 ()>]
3731: 2 [#<procedure 1aed340 at ice-9/boot-9.scm:3724:3 ()>]
In unknown file:
   ?: 1 [load-compiled/vm
"/home/aleix/.cache/guile/ccache/2.0-LE-8-2.0/home/aleix/src/guile/guile-cookbook/recipe-3/recipe-3.scm.go"]
   ?: 0 [simple-format #t ...]

ERROR: In procedure simple-format:
ERROR: In procedure simple-format: FORMAT: Unsupported format option
~d - use (ice-9 format) instead

It seems to me that simple-format is saved in the compiled file,
instead of format.

Is this normal? Did I do anything wrong? The other question I had is
that I did not include "(use-modules (ice-9 format))" and it seems
included by default:

Enter `,help' for help.
scheme@(guile-user)> format
$1 = #<procedure 26aaae0 at ice-9/format.scm:1612:9 (destination
format-string . args) | (deprecated-format-string-only)>

I'm running 2.0.5.90-c0580.

Thanks,

Aleix