From unknown Mon Jun 23 09:37:41 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15533: optimizing away noticeable effects Resent-From: Ian Price Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 05 Oct 2013 19:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 15533 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 15533@debbugs.gnu.org X-Debbugs-Original-To: bug-guile@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.138100131312672 (code B ref -1); Sat, 05 Oct 2013 19:29:01 +0000 Received: (at submit) by debbugs.gnu.org; 5 Oct 2013 19:28:33 +0000 Received: from localhost ([127.0.0.1]:56480 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSXWj-0003IK-BZ for submit@debbugs.gnu.org; Sat, 05 Oct 2013 15:28:33 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40133) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSXWh-0003IB-1F for submit@debbugs.gnu.org; Sat, 05 Oct 2013 15:28:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VSXWb-00028Q-BP for submit@debbugs.gnu.org; Sat, 05 Oct 2013 15:28:30 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:36697) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSXWb-00028L-82 for submit@debbugs.gnu.org; Sat, 05 Oct 2013 15:28:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSXWV-0002pK-Vn for bug-guile@gnu.org; Sat, 05 Oct 2013 15:28:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VSXWQ-00026P-WD for bug-guile@gnu.org; Sat, 05 Oct 2013 15:28:19 -0400 Received: from plane.gmane.org ([80.91.229.3]:39187) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSXWQ-00026L-PP for bug-guile@gnu.org; Sat, 05 Oct 2013 15:28:14 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VSXWL-0000Q6-VH for bug-guile@gnu.org; Sat, 05 Oct 2013 21:28:09 +0200 Received: from host86-132-92-201.range86-132.btcentralplus.com ([86.132.92.201]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Oct 2013 21:28:09 +0200 Received: from ianprice90 by host86-132-92-201.range86-132.btcentralplus.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Oct 2013 21:28:09 +0200 X-Injected-Via-Gmane: http://gmane.org/ From: Ian Price Date: Sat, 05 Oct 2013 20:27:55 +0100 Lines: 53 Message-ID: <87bo33cybo.fsf@Kagami.home> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: host86-132-92-201.range86-132.btcentralplus.com User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) Cancel-Lock: sha1:Naxf818u/PReam+5uPynIsWd0Cc= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) 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" From unknown Mon Jun 23 09:37:41 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15533: optimizing away noticeable effects Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 05 Oct 2013 20:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15533 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Ian Price Cc: 15533@debbugs.gnu.org Received: via spool by 15533-submit@debbugs.gnu.org id=B15533.138100491418208 (code B ref 15533); Sat, 05 Oct 2013 20:29:01 +0000 Received: (at 15533) by debbugs.gnu.org; 5 Oct 2013 20:28:34 +0000 Received: from localhost ([127.0.0.1]:56562 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSYSn-0004jc-KD for submit@debbugs.gnu.org; Sat, 05 Oct 2013 16:28:33 -0400 Received: from world.peace.net ([96.39.62.75]:59749) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSYSm-0004jU-12 for 15533@debbugs.gnu.org; Sat, 05 Oct 2013 16:28:32 -0400 Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1VSYSf-00014e-Tg; Sat, 05 Oct 2013 16:28:26 -0400 From: Mark H Weaver References: <87bo33cybo.fsf@Kagami.home> Date: Sat, 05 Oct 2013 16:28:02 -0400 In-Reply-To: <87bo33cybo.fsf@Kagami.home> (Ian Price's message of "Sat, 05 Oct 2013 20:27:55 +0100") Message-ID: <87ioxba2el.fsf@netris.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Ian Price writes: > 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)))) I can confirm that the same thing happens on the stable-2.0 branch. Mark From unknown Mon Jun 23 09:37:41 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15533: optimizing away noticeable effects Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 05 Oct 2013 20:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15533 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Ian Price Cc: 15533@debbugs.gnu.org Received: via spool by 15533-submit@debbugs.gnu.org id=B15533.138100599420013 (code B ref 15533); Sat, 05 Oct 2013 20:47:02 +0000 Received: (at 15533) by debbugs.gnu.org; 5 Oct 2013 20:46:34 +0000 Received: from localhost ([127.0.0.1]:56600 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSYkD-0005Cj-Nl for submit@debbugs.gnu.org; Sat, 05 Oct 2013 16:46:33 -0400 Received: from world.peace.net ([96.39.62.75]:59761) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSYk8-0005CX-JE for 15533@debbugs.gnu.org; Sat, 05 Oct 2013 16:46:32 -0400 Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1VSYk2-00017S-Fn; Sat, 05 Oct 2013 16:46:22 -0400 From: Mark H Weaver References: <87bo33cybo.fsf@Kagami.home> <87ioxba2el.fsf@netris.org> Date: Sat, 05 Oct 2013 16:45:59 -0400 In-Reply-To: <87ioxba2el.fsf@netris.org> (Mark H. Weaver's message of "Sat, 05 Oct 2013 16:28:02 -0400") Message-ID: <87eh7za1ko.fsf@netris.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Mark H Weaver writes: > Ian Price writes: > >> 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)))) > > I can confirm that the same thing happens on the stable-2.0 branch. Further investigation has revealed that 'peval' incorrectly removes the 'l' from the call to 'apply'. Mark From unknown Mon Jun 23 09:37:41 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15533: optimizing away noticeable effects Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 06 Oct 2013 06:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15533 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Ian Price Cc: 15533@debbugs.gnu.org Received: via spool by 15533-submit@debbugs.gnu.org id=B15533.13810415789984 (code B ref 15533); Sun, 06 Oct 2013 06:40:02 +0000 Received: (at 15533) by debbugs.gnu.org; 6 Oct 2013 06:39:38 +0000 Received: from localhost ([127.0.0.1]:57135 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSi09-0002ay-BE for submit@debbugs.gnu.org; Sun, 06 Oct 2013 02:39:37 -0400 Received: from world.peace.net ([96.39.62.75]:60185) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSi05-0002am-3l for 15533@debbugs.gnu.org; Sun, 06 Oct 2013 02:39:33 -0400 Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1VShzy-000256-Dl; Sun, 06 Oct 2013 02:39:26 -0400 From: Mark H Weaver References: <87bo33cybo.fsf@Kagami.home> <87ioxba2el.fsf@netris.org> <87eh7za1ko.fsf@netris.org> Date: Sun, 06 Oct 2013 02:39:00 -0400 In-Reply-To: <87eh7za1ko.fsf@netris.org> (Mark H. Weaver's message of "Sat, 05 Oct 2013 16:45:59 -0400") Message-ID: <871u3yaoor.fsf@netris.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Mark H Weaver writes: > Mark H Weaver writes: > >> Ian Price writes: >> >>> 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)))) >> >> I can confirm that the same thing happens on the stable-2.0 branch. > > Further investigation has revealed that 'peval' incorrectly removes the > 'l' from the call to 'apply'. stis pointed out that 2.0.5 does not have this bug. I'm currently doing a git bisect to determine which commit introduced the bug. Mark From unknown Mon Jun 23 09:37:41 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15533: optimizing away noticeable effects Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 06 Oct 2013 07:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15533 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Ian Price Cc: Andy Wingo , 15533@debbugs.gnu.org Received: via spool by 15533-submit@debbugs.gnu.org id=B15533.138104501015075 (code B ref 15533); Sun, 06 Oct 2013 07:37:01 +0000 Received: (at 15533) by debbugs.gnu.org; 6 Oct 2013 07:36:50 +0000 Received: from localhost ([127.0.0.1]:57170 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSitV-0003v4-6e for submit@debbugs.gnu.org; Sun, 06 Oct 2013 03:36:49 -0400 Received: from world.peace.net ([96.39.62.75]:60213) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSitS-0003uu-32 for 15533@debbugs.gnu.org; Sun, 06 Oct 2013 03:36:46 -0400 Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1VSitK-00029u-R1; Sun, 06 Oct 2013 03:36:39 -0400 From: Mark H Weaver References: <87bo33cybo.fsf@Kagami.home> <87ioxba2el.fsf@netris.org> <87eh7za1ko.fsf@netris.org> <871u3yaoor.fsf@netris.org> Date: Sun, 06 Oct 2013 03:36:13 -0400 In-Reply-To: <871u3yaoor.fsf@netris.org> (Mark H. Weaver's message of "Sun, 06 Oct 2013 02:39:00 -0400") Message-ID: <87siwe97gy.fsf@netris.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Ian Price writes: > 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)))) Using git bisect, I've determined that this bug was introduced in the following commit: commit d21537efb4a0edea30a7ab801909207d4bb69030 Author: Andy Wingo Date: Fri Feb 15 12:11:29 2013 +0100 better inlining of `apply' with rest arguments * module/language/tree-il/peval.scm (peval): Move up the find-definition helper. Use it to speculatively destructure conses and lists into the tail position of an `apply' form. * test-suite/tests/peval.test ("partial evaluation"): Add tests. Andy, would you be willing to investigate further? Mark From unknown Mon Jun 23 09:37:41 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15533: optimizing away noticeable effects Resent-From: Ian Price Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 07 Oct 2013 16:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15533 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Mark H Weaver Cc: 15533@debbugs.gnu.org Received: via spool by 15533-submit@debbugs.gnu.org id=B15533.138116494619974 (code B ref 15533); Mon, 07 Oct 2013 16:56:01 +0000 Received: (at 15533) by debbugs.gnu.org; 7 Oct 2013 16:55:46 +0000 Received: from localhost ([127.0.0.1]:60657 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VTE5x-0005C5-8p for submit@debbugs.gnu.org; Mon, 07 Oct 2013 12:55:45 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:59883) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VTE5u-0005Bv-Bj for 15533@debbugs.gnu.org; Mon, 07 Oct 2013 12:55:43 -0400 Received: by mail-wi0-f172.google.com with SMTP id hn9so5158586wib.5 for <15533@debbugs.gnu.org>; Mon, 07 Oct 2013 09:55:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=wdeA9M29+3kWJmHF+LraActBJExpDNkTxDjW4J9JJEE=; b=uaw+7QGIUYiMm20kwPoQFnjpK2EFU1LV5FxrXGgv4iqtodnAk/xsbpj/COzEvxmHUg boQxKkfaZcNBZuwenorwgtGbqfIIB4XB1M9ScytLWRPxtYOYUL9ol8YIKongl8tKEv3F Kq7SgGMSoYROT8vw4PI2SZtgd3fGS9IE9oSsRtFsQvC5OysRMfbk0NWwS9s+DsRLv1NI buPWFvwxVyIftmIOVxoDxlYalJYlWep4zVqop8izYranZBpVABuS1Z3qUDdE0kWOGqPf duEilfKSSZISZBl50HKMu8MlNJ4mWRD67drk8X3MhxIAMlmpmEHCm14QbnSqlecrZp4+ L/qw== X-Received: by 10.180.9.139 with SMTP id z11mr6278892wia.22.1381164941362; Mon, 07 Oct 2013 09:55:41 -0700 (PDT) Received: from Kagami.home (host86-132-92-201.range86-132.btcentralplus.com. [86.132.92.201]) by mx.google.com with ESMTPSA id ft19sm5125736wic.5.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 07 Oct 2013 09:55:40 -0700 (PDT) From: Ian Price References: <87bo33cybo.fsf@Kagami.home> <87ioxba2el.fsf@netris.org> <87eh7za1ko.fsf@netris.org> <871u3yaoor.fsf@netris.org> <87siwe97gy.fsf@netris.org> Date: Mon, 07 Oct 2013 17:55:36 +0100 In-Reply-To: <87siwe97gy.fsf@netris.org> (Mark H. Weaver's message of "Sun, 06 Oct 2013 03:36:13 -0400") Message-ID: <877gdpc96f.fsf@Kagami.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.4 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) Mark H Weaver writes: > Using git bisect, I've determined that this bug was introduced in the > following commit: > > commit d21537efb4a0edea30a7ab801909207d4bb69030 > Author: Andy Wingo > Date: Fri Feb 15 12:11:29 2013 +0100 > > better inlining of `apply' with rest arguments > > * module/language/tree-il/peval.scm (peval): Move up the find-definition > helper. Use it to speculatively destructure conses and lists into the > tail position of an `apply' form. > > * test-suite/tests/peval.test ("partial evaluation"): Add tests. Thanks for bisecting mark, I've had a little look and this is the right patch. The actual error occurs at the very beginning of the loop, in the variable tail*. Originally, this was a call (for-value tail), which returned a lexical-ref. Now it is a call (find-definition tail) which returns a const (). We obviously need to have a check for mutability when referring to a variable, the question is where? Does it make sense to add it to find-definition? or should we add it before the use in that case? -- 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" From unknown Mon Jun 23 09:37:41 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15533: optimizing away noticeable effects Resent-From: Ian Price Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 08 Oct 2013 17:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15533 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Mark H Weaver Cc: Andy Wingo , 15533@debbugs.gnu.org Received: via spool by 15533-submit@debbugs.gnu.org id=B15533.13812523978730 (code B ref 15533); Tue, 08 Oct 2013 17:14:02 +0000 Received: (at 15533) by debbugs.gnu.org; 8 Oct 2013 17:13:17 +0000 Received: from localhost ([127.0.0.1]:35321 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VTaqS-0002Gj-HX for submit@debbugs.gnu.org; Tue, 08 Oct 2013 13:13:17 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:51008) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VTaqP-0002Ga-MR for 15533@debbugs.gnu.org; Tue, 08 Oct 2013 13:13:14 -0400 Received: by mail-wi0-f177.google.com with SMTP id hq15so1162743wib.10 for <15533@debbugs.gnu.org>; Tue, 08 Oct 2013 10:13:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=REOFLzZ/Chij3M8jI5IHjVFTko0rG3XXTvCsGleCqiA=; b=tewd+g14xmbQezkpMHeNOhSYUkSx06Ie9wIKFVKNqc1ZjqSFnXahDxHu9VMGo1Y6ia 4PPMagPeb6fi4ZpvYIg8OLD0q+v4i9Xd5eJZC3jO7tGU9hbOE8k6qmA4/Oous+/ytUpp jnclOIC48mtPDVv4pVyVjbaxEGVtQVYw86vCU+sC6qbemw7mSFPbWowXwJ2mJuX+sZ5M o8hsnLCoShS5BaXOK20+g8Ca2PM11/W/1TqiCkewRyOQY11vq68Gt99qajUvp3Hb2HKm DluZOMCHA0nHcNOF3rZoerZIKguXTWzoseUpFl+BHIPkHb0XjfKZJ180fDq2/5VNXFGA D9SQ== X-Received: by 10.180.12.45 with SMTP id v13mr24339758wib.57.1381252392866; Tue, 08 Oct 2013 10:13:12 -0700 (PDT) Received: from Kagami.home (host86-132-92-201.range86-132.btcentralplus.com. [86.132.92.201]) by mx.google.com with ESMTPSA id e1sm6990023wij.6.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 08 Oct 2013 10:13:11 -0700 (PDT) From: Ian Price References: <87bo33cybo.fsf@Kagami.home> <87ioxba2el.fsf@netris.org> <87eh7za1ko.fsf@netris.org> <871u3yaoor.fsf@netris.org> <87siwe97gy.fsf@netris.org> <877gdpc96f.fsf@Kagami.home> Date: Tue, 08 Oct 2013 18:13:05 +0100 In-Reply-To: <877gdpc96f.fsf@Kagami.home> (Ian Price's message of "Mon, 07 Oct 2013 17:55:36 +0100") Message-ID: <8738obd6u6.fsf@Kagami.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.4 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) Ian Price writes: > Does it make sense to add it to find-definition? or should we add it > before the use in that case? I've decided that it does, and I've made the following (tentative) change on my own guile install. (cond ((lookup (lexical-ref-gensym x)) => (lambda (op) - (let ((y (or (operand-residual-value op) - (visit-operand op counter 'value 10 10) - (operand-source op)))) - (cond - ((and (lexical-ref? y) - (= (lexical-refcount (lexical-ref-gensym x)) 1)) - ;; X is a simple alias for Y. Recurse, regardless of - ;; the number of aliases we were expecting. - (find-definition y n-aliases)) - ((= (lexical-refcount (lexical-ref-gensym x)) n-aliases) - ;; We found a definition that is aliased the right - ;; number of times. We still recurse in case it is a - ;; lexical. - (values (find-definition y 1) - op)) - (else - ;; We can't account for our aliases. - (values #f #f)))))) + (if (var-set? (operand-var op)) + (values #f #f) + + ;; var-set? (operand-var ) => #f #f ? + (let ((y (or (operand-residual-value op) + (visit-operand op counter 'value 10 10) + (operand-source op)))) + (cond + ((and (lexical-ref? y) + (= (lexical-refcount (lexical-ref-gensym x)) 1)) + ;; X is a simple alias for Y. Recurse, regardless of + ;; the number of aliases we were expecting. + (find-definition y n-aliases)) + ((= (lexical-refcount (lexical-ref-gensym x)) n-aliases) + ;; We found a definition that is aliased the right + ;; number of times. We still recurse in case it is a + ;; lexical. + (values (find-definition y 1) + op)) + (else + ;; We can't account for our aliases. + (values #f #f))))))) It's a little invasive because of the 'if', but the meat of it is + (if (var-set? (operand-var op)) + (values #f #f) The check for mutability needs to come before the let, since that's where we do the lookup for a value, so it would be too late. If Andy is happy with this change, I'll add a test, and push a commit, but I'm going leave it to his discretion. -- 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" From unknown Mon Jun 23 09:37:41 2025 X-Loop: help-debbugs@gnu.org Subject: bug#15533: optimizing away noticeable effects Resent-From: Ian Price Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 23 Oct 2013 10:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15533 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Mark H Weaver Cc: 15533@debbugs.gnu.org Received: via spool by 15533-submit@debbugs.gnu.org id=B15533.13825234072139 (code B ref 15533); Wed, 23 Oct 2013 10:17:02 +0000 Received: (at 15533) by debbugs.gnu.org; 23 Oct 2013 10:16:47 +0000 Received: from localhost ([127.0.0.1]:37089 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VYvUc-0000YL-RC for submit@debbugs.gnu.org; Wed, 23 Oct 2013 06:16:47 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:46947) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VYvUa-0000Y5-5D for 15533@debbugs.gnu.org; Wed, 23 Oct 2013 06:16:45 -0400 Received: by mail-wi0-f175.google.com with SMTP id hm4so7065315wib.14 for <15533@debbugs.gnu.org>; Wed, 23 Oct 2013 03:16:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=TbwUEbQfMjPH1fE0p16vzoMaqtso1CEg0fV88+uSV58=; b=nkpv0BMpMppukUzAys+5gRSiYCSGOWheH5M75g3qgko6y4CqFogTxgFExiKizxhLj8 iBoQx/dzxrvsWVZLuC58DWQgFSPYbgqmrS1slZR19gyKEQ9tL1uygAf5/oXEepa6cW48 FS9Kpk0yykiF1BLkq4uMBGZXS7xyY6bGfCUhDTB45Pjbla3WRm+ortviSGftepYKcaO+ NiTwUTweGYOzfygo5cf7ofsNn/DipdnXVU5JRNwGlppb7EQO0l1Cx4vcYlskKZRNBT0Z Md5+cxj7UpdnpcG+ZXabiLfiv5uzNJgwKxn358vs/4uBPoX+UEICsFR6rDKzKoKETruB zsgw== X-Received: by 10.194.173.163 with SMTP id bl3mr958672wjc.10.1382523398150; Wed, 23 Oct 2013 03:16:38 -0700 (PDT) Received: from Kagami.home (host86-132-92-201.range86-132.btcentralplus.com. [86.132.92.201]) by mx.google.com with ESMTPSA id b13sm15318773wic.9.2013.10.23.03.16.35 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 23 Oct 2013 03:16:37 -0700 (PDT) From: Ian Price References: <87bo33cybo.fsf@Kagami.home> <87ioxba2el.fsf@netris.org> <87eh7za1ko.fsf@netris.org> <871u3yaoor.fsf@netris.org> <87siwe97gy.fsf@netris.org> <877gdpc96f.fsf@Kagami.home> <8738obd6u6.fsf@Kagami.home> Date: Wed, 23 Oct 2013 11:16:31 +0100 In-Reply-To: <8738obd6u6.fsf@Kagami.home> (Ian Price's message of "Tue, 08 Oct 2013 18:13:05 +0100") Message-ID: <87li1kxpfk.fsf@Kagami.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.4 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) --=-=-= Content-Type: text/plain Ian Price writes: > If Andy is happy with this change, I'll add a test, and push a commit, > but I'm going leave it to his discretion. Andy OKed it on IRC, so I've attached the patch. -- 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" --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Fix-inlining-of-tail-list-to-apply.patch Content-Description: peval fix >From ee6b0bb09dbf48e83c6e0ac7b7f1699bae34108a Mon Sep 17 00:00:00 2001 From: Ian Price Date: Wed, 23 Oct 2013 11:14:26 +0100 Subject: [PATCH] Fix inlining of tail list to apply. Fixes . * module/language/tree-il/peval.scm (peval): Final list argument to `apply' should not be inlined if it is mutable. * test-suite/tests/peval.test ("partial evaluation"): Add test. --- module/language/tree-il/peval.scm | 38 ++++++++++++++++++++------------------ test-suite/tests/peval.test | 16 +++++++++++++++- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/module/language/tree-il/peval.scm b/module/language/tree-il/peval.scm index a6e4076..bd92edc 100644 --- a/module/language/tree-il/peval.scm +++ b/module/language/tree-il/peval.scm @@ -716,24 +716,26 @@ top-level bindings from ENV and return the resulting expression." (cond ((lookup (lexical-ref-gensym x)) => (lambda (op) - (let ((y (or (operand-residual-value op) - (visit-operand op counter 'value 10 10) - (operand-source op)))) - (cond - ((and (lexical-ref? y) - (= (lexical-refcount (lexical-ref-gensym x)) 1)) - ;; X is a simple alias for Y. Recurse, regardless of - ;; the number of aliases we were expecting. - (find-definition y n-aliases)) - ((= (lexical-refcount (lexical-ref-gensym x)) n-aliases) - ;; We found a definition that is aliased the right - ;; number of times. We still recurse in case it is a - ;; lexical. - (values (find-definition y 1) - op)) - (else - ;; We can't account for our aliases. - (values #f #f)))))) + (if (var-set? (operand-var op)) + (values #f #f) + (let ((y (or (operand-residual-value op) + (visit-operand op counter 'value 10 10) + (operand-source op)))) + (cond + ((and (lexical-ref? y) + (= (lexical-refcount (lexical-ref-gensym x)) 1)) + ;; X is a simple alias for Y. Recurse, regardless of + ;; the number of aliases we were expecting. + (find-definition y n-aliases)) + ((= (lexical-refcount (lexical-ref-gensym x)) n-aliases) + ;; We found a definition that is aliased the right + ;; number of times. We still recurse in case it is a + ;; lexical. + (values (find-definition y 1) + op)) + (else + ;; We can't account for our aliases. + (values #f #f))))))) (else ;; A formal parameter. Can't say anything about that. (values #f #f)))) diff --git a/test-suite/tests/peval.test b/test-suite/tests/peval.test index 923b0d1..5b003d2 100644 --- a/test-suite/tests/peval.test +++ b/test-suite/tests/peval.test @@ -1223,4 +1223,18 @@ (call-with-prompt t (lambda () (abort-to-prompt t 1 2 3)) (lambda (k x y z) (list x y z)))) - (apply (primitive 'list) (const 1) (const 2) (const 3)))) + (apply (primitive 'list) (const 1) (const 2) (const 3))) + + (pass-if-peval resolve-primitives + ;; Should not inline tail list to apply if it is mutable. + ;; + (let ((l '())) + (if (pair? arg) + (set! l arg)) + (apply f l)) + (let (l) (_) ((const ())) + (begin + (if (apply (primitive pair?) (toplevel arg)) + (set! (lexical l _) (toplevel arg)) + (void)) + (apply (primitive @apply) (toplevel f) (lexical l _)))))) -- 1.7.11.7 --=-=-=-- From unknown Mon Jun 23 09:37:41 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Ian Price Subject: bug#15533: closed (Re: bug#15533: optimizing away noticeable effects) Message-ID: References: <87d2k4be40.fsf@Kagami.home> <87bo33cybo.fsf@Kagami.home> X-Gnu-PR-Message: they-closed 15533 X-Gnu-PR-Package: guile Reply-To: 15533@debbugs.gnu.org Date: Tue, 07 Jan 2014 04:39:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1389069542-10691-1" This is a multi-part message in MIME format... ------------=_1389069542-10691-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 15533@debbugs.gnu.org. --=20 15533: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D15533 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1389069542-10691-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 15533-done) by debbugs.gnu.org; 7 Jan 2014 04:38:50 +0000 Received: from localhost ([127.0.0.1]:39902 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W0ORF-0002m1-Uq for submit@debbugs.gnu.org; Mon, 06 Jan 2014 23:38:50 -0500 Received: from mail-wi0-f181.google.com ([209.85.212.181]:42037) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W0ORD-0002ls-25 for 15533-done@debbugs.gnu.org; Mon, 06 Jan 2014 23:38:48 -0500 Received: by mail-wi0-f181.google.com with SMTP id hq4so220748wib.8 for <15533-done@debbugs.gnu.org>; Mon, 06 Jan 2014 20:38:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version:content-type; bh=WOEPJGvtWO9nFHVQa4hSApy7low2wINSzRUdTiV48QM=; b=miigA4AUVAs6QU9Q3ts2MsEi2v6Iwy91P+RjJ6Oz//uNmT5eOEj5hhChrjzSnCHy7g 63aHzTPO2oaiTvDUsZnBJDgF4EfangytfCJ5Cp+4DwVGrdwnmcj14AUYxbXmJTzJzr7t 1VR29rWborjJBPVAWU31hXcjRfYnG+fECBRysfIoSzH3fRdw2q3QEuLF/pDLHWEsZTa2 JTITWBBOT0fW49bab7U07ImT6D+y+ZHPYu+VTDjexY/0vXTqd6DPiVdHzBgedidI3DjP we8pwHnQzBhr5CgoZJLf3c9tDcvU+v2nIhENjgx7ZDSfqeb/D5w/gjoWJ0fKWqsvXT+Z dWuA== X-Received: by 10.180.211.141 with SMTP id nc13mr9237755wic.47.1389069526240; Mon, 06 Jan 2014 20:38:46 -0800 (PST) Received: from Kagami.home (host86-184-83-158.range86-184.btcentralplus.com. [86.184.83.158]) by mx.google.com with ESMTPSA id ci4sm44298396wjc.21.2014.01.06.20.38.43 for <15533-done@debbugs.gnu.org> (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 06 Jan 2014 20:38:44 -0800 (PST) From: Ian Price To: 15533-done@debbugs.gnu.org Subject: Re: bug#15533: optimizing away noticeable effects References: <87bo33cybo.fsf@Kagami.home> <87ioxba2el.fsf@netris.org> <87eh7za1ko.fsf@netris.org> <871u3yaoor.fsf@netris.org> <87siwe97gy.fsf@netris.org> <877gdpc96f.fsf@Kagami.home> <8738obd6u6.fsf@Kagami.home> <87li1kxpfk.fsf@Kagami.home> Date: Tue, 07 Jan 2014 04:38:39 +0000 In-Reply-To: <87li1kxpfk.fsf@Kagami.home> (Ian Price's message of "Wed, 23 Oct 2013 11:16:31 +0100") Message-ID: <87d2k4be40.fsf@Kagami.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.4 (/) X-Debbugs-Envelope-To: 15533-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) 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" ------------=_1389069542-10691-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 5 Oct 2013 19:28:33 +0000 Received: from localhost ([127.0.0.1]:56480 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSXWj-0003IK-BZ for submit@debbugs.gnu.org; Sat, 05 Oct 2013 15:28:33 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40133) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSXWh-0003IB-1F for submit@debbugs.gnu.org; Sat, 05 Oct 2013 15:28:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VSXWb-00028Q-BP for submit@debbugs.gnu.org; Sat, 05 Oct 2013 15:28:30 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:36697) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSXWb-00028L-82 for submit@debbugs.gnu.org; Sat, 05 Oct 2013 15:28:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSXWV-0002pK-Vn for bug-guile@gnu.org; Sat, 05 Oct 2013 15:28:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VSXWQ-00026P-WD for bug-guile@gnu.org; Sat, 05 Oct 2013 15:28:19 -0400 Received: from plane.gmane.org ([80.91.229.3]:39187) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSXWQ-00026L-PP for bug-guile@gnu.org; Sat, 05 Oct 2013 15:28:14 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VSXWL-0000Q6-VH for bug-guile@gnu.org; Sat, 05 Oct 2013 21:28:09 +0200 Received: from host86-132-92-201.range86-132.btcentralplus.com ([86.132.92.201]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Oct 2013 21:28:09 +0200 Received: from ianprice90 by host86-132-92-201.range86-132.btcentralplus.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Oct 2013 21:28:09 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: bug-guile@gnu.org From: Ian Price Subject: optimizing away noticeable effects Date: Sat, 05 Oct 2013 20:27:55 +0100 Lines: 53 Message-ID: <87bo33cybo.fsf@Kagami.home> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: host86-132-92-201.range86-132.btcentralplus.com User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) Cancel-Lock: sha1:Naxf818u/PReam+5uPynIsWd0Cc= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) 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" ------------=_1389069542-10691-1--