GNU bug report logs -
#13865
redefinition of +
Previous Next
Reported by: Ian Price <ianprice90 <at> googlemail.com>
Date: Mon, 4 Mar 2013 00:44:01 UTC
Severity: normal
Tags: notabug
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 13865 in the body.
You can then email your comments to 13865 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guile <at> gnu.org
:
bug#13865
; Package
guile
.
(Mon, 04 Mar 2013 00:44:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Ian Price <ianprice90 <at> googlemail.com>
:
New bug report received and forwarded. Copy sent to
bug-guile <at> gnu.org
.
(Mon, 04 Mar 2013 00:44:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi guys,
On #guile, euiuer (CCed) reported this, though he was to shy to report
this himself. In guile 1.8.7
<euiuer> (define (foo) (+ 1 1))
<euiuer> (define (+ a b) (- a b))
<euiuer> (display (foo))
<euiuer> (display (+ 1 1))
<euiuer> it evails like 0 and 0.
<euiuer> but..
<euiuer> (define (foo) (+ 1 1))
<euiuer> (display (foo))
<euiuer> (define (+ a b) (- a b))
<euiuer> (display (foo))
<euiuer> (display (+ 1 1))
<euiuer> it evails like 2 2 0
<euiuer> it is kind of odd.
He confirms he gets these when he runs these from a script.
I get the same on my 1.8.8 install, both at the repl and from a script.
Since it evaluates correct if we run (bar) _after_ redefining + I think
it's a safe bet to assume that 1.8 cached the reference to +, but not
having been around for 1.8, this is a conjecture only.
Now, 1.8 is the old series, how about 2? Running a recent master
(9b977c836bf147d386944c401113aba32776fa68)[0].
From the repl:
scheme@(guile−user)> (define (foo) (+ 1 1))
scheme@(guile−user)> (define (+ a b) (- a b))
scheme@(guile−user)> (foo)
$2 = 2
scheme@(guile−user)> (+ 1 1)
$3 = 0
and
scheme@(guile−user)> (define (foo) (+ 1 1))
scheme@(guile−user)> (foo)
$2 = 2
scheme@(guile−user)> (define (+ a b) (- a b))
scheme@(guile−user)> (foo)
$3 = 2
scheme@(guile−user)> (+ 1 1)
$4 = 0
From a script
$ guile -q -s /tmp/file1.scm
22
$ guile -q -s /tmp/file2.scm
222
This behaviour can be "blamed" on guile 2's more aggressive
optimisation. Indeed,
scheme@(guile−user)> ,disassemble foo
Disassembly of #<procedure foo ()>:
0 (assert−nargs−ee/locals 0) ;; 0 args, 0 locals
2 (make−int8 2) ;; 2 at (unknown file):5:14
4 (return)
is pretty much what we want usually. And I'm inclined to say NOTABUG for
the repl when optimisation is turned on. However, in a script, this is a
bug IMO, since we shouldn't really be optimising + if our top-level
binding for + is not the builtin one, and we can certainly detect a
redefinition of + within a file.
Just to be sure, I tried turning off cse and peal, but ran into a
different optimisation
scheme@(guile−user)> ,option compile-options (#:partial-eval? #f #:cse? #f)
scheme@(guile−user)> ,option compile-options
(#:partial−eval? #f #:cse? #f)
scheme@(guile−user)> (foo)
$2 = 2
scheme@(guile−user)> (+ )
$3 = 0
scheme@(guile−user)> (define (+ a b) (- a b))
scheme@(guile−user)> (foo)
$4 = 2
scheme@(guile−user)> (+ 1 1)
$5 = 0
Have you guessed what it was?
scheme@(guile−user)> ,disassemble foo
Disassembly of #<procedure foo ()>:
0 (assert−nargs−ee/locals 0) ;; 0 args, 0 locals
2 (make−int8:1) ;; 1
3 (add1) at (unknown file):44:14
4 (return)
So, you can't win on this one :)
[0] I have not got a stable-2.0 install at the moment to compare, but I
suspect it will be similar.
--
Ian Price -- shift-reset.com
"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"
Information forwarded
to
bug-guile <at> gnu.org
:
bug#13865
; Package
guile
.
(Mon, 04 Mar 2013 13:35:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 13865 <at> debbugs.gnu.org (full text, mbox):
close 13865
tag 13865 notabug
thanks
Ian Price <ianprice90 <at> googlemail.com> skribis:
> is pretty much what we want usually. And I'm inclined to say NOTABUG for
> the repl when optimisation is turned on. However, in a script, this is a
> bug IMO, since we shouldn't really be optimising + if our top-level
> binding for + is not the builtin one, and we can certainly detect a
> redefinition of + within a file.
The REPL is different from a “real” program.
In a stand-alone file like this:
--8<---------------cut here---------------start------------->8---
(define (+ a b) (- a b))
(pk (+ 1 1))
--8<---------------cut here---------------end--------------->8---
You get the expected behavior, because top-level ‘define’ is like
‘letrec*’.
So closing it as not-a-bug. Let us know if you think of actions to be
taken.
Thanks,
Ludo’.
bug closed, send any further explanations to
13865 <at> debbugs.gnu.org and Ian Price <ianprice90 <at> googlemail.com>
Request was from
ludo <at> gnu.org (Ludovic Courtès)
to
control <at> debbugs.gnu.org
.
(Mon, 04 Mar 2013 13:35:02 GMT)
Full text and
rfc822 format available.
Added tag(s) notabug.
Request was from
ludo <at> gnu.org (Ludovic Courtès)
to
control <at> debbugs.gnu.org
.
(Mon, 04 Mar 2013 13:35:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-guile <at> gnu.org
:
bug#13865
; Package
guile
.
(Mon, 04 Mar 2013 14:25:01 GMT)
Full text and
rfc822 format available.
Message #15 received at 13865 <at> debbugs.gnu.org (full text, mbox):
ludo <at> gnu.org (Ludovic Court$(D+2(Bs) writes:
> close 13865
> tag 13865 notabug
> thanks
>
> Ian Price <ianprice90 <at> googlemail.com> skribis:
>
>> is pretty much what we want usually. And I'm inclined to say NOTABUG for
>> the repl when optimisation is turned on. However, in a script, this is a
>> bug IMO, since we shouldn't really be optimising + if our top-level
>> binding for + is not the builtin one, and we can certainly detect a
>> redefinition of + within a file.
>
> The REPL is different from a $B!H(Breal$B!I(B program.
>
> In a stand-alone file like this:
>
> (define (+ a b) (- a b))
> (pk (+ 1 1))
>
> You get the expected behavior, because top-level $B!F(Bdefine$B!G(B is like
> $B!F(Bletrec*$B!G(B.
>
> So closing it as not-a-bug. Let us know if you think of actions to be
> taken.
Er, screw the repl, but it happens in a script as well.
(define (foo) (+ 1 1))
(define (+ a b) (- a b))
(display (foo))
(display (+ 1 1))
(newline)
$ guile -s /tmp/file1.scm
;;; note: source file /tmp/file1.scm
;;; newer than compiled /home/ian/.cache/guile/ccache/2.2-LE-4-3.1/tmp/file1.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /tmp/file1.scm
;;; compiled /home/ian/.cache/guile/ccache/2.2-LE-4-3.1/tmp/file1.scm.go
22
(letrec* ((foo (lambda () (+ 1 1)))
(+ (lambda (a b) (- a b))))
(display (foo))
(display (+ 1 1))
(newline))
$ guile -s /tmp/file1.scm
;;; note: source file /tmp/file1.scm
;;; newer than compiled /home/ian/.cache/guile/ccache/2.2-LE-4-3.1/tmp/file1.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /tmp/file1.scm
;;; compiled /home/ian/.cache/guile/ccache/2.2-LE-4-3.1/tmp/file1.scm.go
00
If top-level module define is supposed to be a letrec*, it certainly
isn't acting like one.
--
Ian Price -- shift-reset.com
"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"
Information forwarded
to
bug-guile <at> gnu.org
:
bug#13865
; Package
guile
.
(Thu, 07 Mar 2013 21:40:02 GMT)
Full text and
rfc822 format available.
Message #18 received at 13865 <at> debbugs.gnu.org (full text, mbox):
On Mon 04 Mar 2013 15:24, Ian Price <ianprice90 <at> googlemail.com> writes:
> Er, screw the repl, but it happens in a script as well.
>
> (define (foo) (+ 1 1))
> (define (+ a b) (- a b))
> (display (foo))
> (display (+ 1 1))
> (newline)
>
> $ guile -s /tmp/file1.scm
> ;;; note: source file /tmp/file1.scm
> ;;; newer than compiled /home/ian/.cache/guile/ccache/2.2-LE-4-3.1/tmp/file1.scm.go
> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
> ;;; or pass the --no-auto-compile argument to disable.
> ;;; compiling /tmp/file1.scm
> ;;; compiled /home/ian/.cache/guile/ccache/2.2-LE-4-3.1/tmp/file1.scm.go
> 22
I see you are on master. Is this a problem only in master?
$ ~/src/guile-master/meta/guile /tmp/foo.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /tmp/foo.scm
;;; compiled /home/wingo/src/guile-master/cache/guile/ccache/2.2-LE-8-3.1/tmp/foo.scm.go
22
$ ~/src/guile/meta/guile /tmp/foo.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /tmp/foo.scm
;;; compiled /home/wingo/src/guile/cache/guile/ccache/2.0-LE-8-2.0/tmp/foo.scm.go
00
Andy
--
http://wingolog.org/
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 05 Apr 2013 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 12 years and 139 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.