GNU bug report logs - #11293
format and simple-format confused after compiling

Previous Next

Package: guile;

Reported by: Aleix Conchillo Flaqué <aconchillo <at> gmail.com>

Date: Sat, 21 Apr 2012 06:45:01 UTC

Severity: normal

Done: ludo <at> gnu.org (Ludovic Courtès)

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11293 in the body.
You can then email your comments to 11293 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#11293; Package guile. (Sat, 21 Apr 2012 06:45:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Aleix Conchillo Flaqué <aconchillo <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sat, 21 Apr 2012 06:45:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Aleix Conchillo Flaqué <aconchillo <at> gmail.com>
To: bug-guile <at> gnu.org
Subject: format and simple-format confused after compiling
Date: Fri, 20 Apr 2012 23:43:46 -0700
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




Reply sent to ludo <at> gnu.org (Ludovic Courtès):
You have taken responsibility. (Sat, 21 Apr 2012 23:32:02 GMT) Full text and rfc822 format available.

Notification sent to Aleix Conchillo Flaqué <aconchillo <at> gmail.com>:
bug acknowledged by developer. (Sat, 21 Apr 2012 23:32:03 GMT) Full text and rfc822 format available.

Message #10 received at 11293-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Aleix Conchillo Flaqué <aconchillo <at> gmail.com>
Cc: 11293-done <at> debbugs.gnu.org
Subject: Re: bug#11293: format and simple-format confused after compiling
Date: Sun, 22 Apr 2012 01:30:04 +0200
Hi Aleix,

Aleix Conchillo Flaqué <aconchillo <at> gmail.com> 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’.




Message #11 received at 11293-done <at> debbugs.gnu.org (full text, mbox):

From: Aleix Conchillo Flaqué <aconchillo <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 11293-done <at> debbugs.gnu.org
Subject: Re: bug#11293: format and simple-format confused after compiling
Date: Sat, 21 Apr 2012 16:50:01 -0700
On Sat, Apr 21, 2012 at 4:30 PM, Ludovic Courtès <ludo <at> gnu.org> wrote:
>
> 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! I guess it's better to start with GUILE_AUTO_COMPILE=0 until
you are done. Will this happen with other modules then?

Thanks again,

Aleix




Message #12 received at 11293-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Aleix Conchillo Flaqué <aconchillo <at> gmail.com>
Cc: 11293-done <at> debbugs.gnu.org
Subject: Re: bug#11293: format and simple-format confused after compiling
Date: Sun, 22 Apr 2012 12:08:44 +0200
Hi,

Aleix Conchillo Flaqué <aconchillo <at> gmail.com> skribis:

> On Sat, Apr 21, 2012 at 4:30 PM, Ludovic Courtès <ludo <at> gnu.org> wrote:
>>
>> 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! I guess it's better to start with GUILE_AUTO_COMPILE=0 until
> you are done.

To make sure there’s no misunderstanding: the fix is to import
(ice-9 format) in your module.

> Will this happen with other modules then?

No, (ice-9 format) is the only one that does that AFAIK.

It shouldn’t do this ‘set!’, but removing it is likely to break code
that has come to rely on it, so I guess we’ll have to leave it in.

Thanks,
Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 20 May 2012 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 94 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.