Subject: bug#15533: closed (Re: bug#15533: optimizing away noticeable effects)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 07 Jan 2014 04:39:02 +0000

Your bug report

#15533: optimizing away noticeable effects

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

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

Subject: Re: bug#15533: optimizing away noticeable effects
From: Ian Price <[email-masked]>
To: [email-masked]
Date: Tue, 07 Jan 2014 04:38:39 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Following prompting from mark weaver on IRC. I rebased this patch, and
pushed to stable-2.0.

-- 
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"

Subject: optimizing away noticeable effects
From: Ian Price <[email-masked]>
To: [email-masked]
Date: Sat, 05 Oct 2013 20:27:55 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

I was peeved today to come across a bug that manifested itself when I
removed a pk from a particular value in my code.

Time to play "spot the difference"

scheme@(guile-user)> ,optimize (define (foo f arg)
  (let* ((l '())
         (m (if (pair? arg)
                (begin
                  (set! l (cdr arg))
                  (car arg))
                arg)))
    (lambda () (apply f m l))))
$14 = (define (foo f arg)
  (let ((m (if (pair? arg)
             (begin (begin (cdr arg) (if #f #f)) (car arg))
             arg)))
    (lambda () (f m))))

scheme@(guile-user)> ,optimize (define (foo2 f arg)
  (let* ((l '())
         (m (if (pair? arg)
                (begin
                  (set! l (cdr arg))
                  (car arg))
                arg)))
    (lambda () (apply f m (pk l)))))
$15 = (define (foo2 f arg)
  (let* ((l '())
         (m (if (pair? arg)
              (begin (set! l (cdr arg)) (car arg))
              arg)))
    (lambda () (apply f m (pk l)))))

and if you actually define those procedures and run them

scheme@(guile-user)> ((foo list '(a b c)))
$16 = (a)
scheme@(guile-user)> ((foo2 list '(a b c)))

;;; ((b c))
$17 = (a b c)

I'm currently on the lua branch, which means branches from master at
6871327742d3e1a0966aa8fed04c911311c12c2a (Aug 31). I'll try on a more
recent master or stable when I have time.

-- 
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"