From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.lisp.guile.devel Subject: Re: Adding Identities to Peval Date: Thu, 16 Feb 2012 09:14:21 +0100 Organization: Organization?!? Message-ID: <87lio3b3fm.fsf@fencepost.gnu.org> References: <87ty2rb9m5.fsf@fencepost.gnu.org> <87pqdfb7tq.fsf@fencepost.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1329380092 30566 80.91.229.3 (16 Feb 2012 08:14:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 16 Feb 2012 08:14:52 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Feb 16 09:14:51 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RxwUN-0007fu-I5 for guile-devel@m.gmane.org; Thu, 16 Feb 2012 09:14:51 +0100 Original-Received: from localhost ([::1]:47245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxwUM-00049m-P0 for guile-devel@m.gmane.org; Thu, 16 Feb 2012 03:14:50 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:33231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxwUG-00049d-4p for guile-devel@gnu.org; Thu, 16 Feb 2012 03:14:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RxwUB-0006kl-V9 for guile-devel@gnu.org; Thu, 16 Feb 2012 03:14:43 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:49076) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxwUB-0006kg-Oj for guile-devel@gnu.org; Thu, 16 Feb 2012 03:14:39 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1RxwU5-0007UT-R3 for guile-devel@gnu.org; Thu, 16 Feb 2012 09:14:33 +0100 Original-Received: from p57b9e808.dip.t-dialin.net ([87.185.232.8]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 16 Feb 2012 09:14:33 +0100 Original-Received: from dak by p57b9e808.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 16 Feb 2012 09:14:33 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 56 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: p57b9e808.dip.t-dialin.net X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) Cancel-Lock: sha1:JBlBsLZ4QpRIsdo9tZW8/5OkwBg= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:13868 Archived-At: David Kastrup writes: > David Kastrup writes: > >> Noah Lavine writes: >> >>> Hello, >>> >>> I've been working on a patch to add a new sort of optimization to >>> peval, and I think it's almost ready. It's based on some of the ideas >>> in "Environment Analysis of Higher-Order Languages". >>> >>> The goal is to recognize when two quantities are equal even when we >>> don't know what they are. My working example has been this expression: >>> >>> (let* ((x (random)) >>> (y x)) >>> (eq? x y)) >>> >>> The patch attached to this message lets peval optimize that to >>> >>> (begin (random) #t) >> >> I have a hard time imagining this optimization to be useful for any code >> occuring in practice. Can you suggest an example that would make more >> sense than demonstrating that the optimization works? Is this supposed >> to help with automatically generated code like macros? > > Actually, I've been just racking my brain over how to write this better: > > { > // We end only one slur unless several ones have been > // caused by the same event, like with double slurs. > if (!ended || scm_is_eq (starter, > slurs_[j]->get_property ("cause"))) > { > ended = true; > starter = slurs_[j]->get_property ("cause"); > end_slurs_.push_back (slurs_[j]); > slurs_.erase (slurs_.begin () + j); > } > } > > The problem is that if you enter the "if" through the second alternative > condition, you can just jump past the first two assignments (because > they assign values that are already known to be in the respective > variables). I've not found a good way to handoptimize this short of > using goto or abusing do ... while; So if you want to make this into some sort of feedback: in this particular case, the equality of some variables is not known because one has been assigned to another, but because one has arrived from a code path where the equality has been established by a test. -- David Kastrup