From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: Adding Identities to Peval Date: Thu, 16 Feb 2012 10:36:51 +0100 Message-ID: <87mx8jjf0s.fsf@pobox.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1329385036 1775 80.91.229.3 (16 Feb 2012 09:37:16 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 16 Feb 2012 09:37:16 +0000 (UTC) Cc: guile-devel To: Noah Lavine Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Feb 16 10:37:10 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 1Rxxm2-0001N1-He for guile-devel@m.gmane.org; Thu, 16 Feb 2012 10:37:10 +0100 Original-Received: from localhost ([::1]:46821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rxxm2-000704-1f for guile-devel@m.gmane.org; Thu, 16 Feb 2012 04:37:10 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:38322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rxxlv-0006yf-1U for guile-devel@gnu.org; Thu, 16 Feb 2012 04:37:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rxxlo-0004Rh-Rs for guile-devel@gnu.org; Thu, 16 Feb 2012 04:37:03 -0500 Original-Received: from a-pb-sasl-sd.pobox.com ([74.115.168.62]:42084 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rxxlo-0004RX-KE for guile-devel@gnu.org; Thu, 16 Feb 2012 04:36:56 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id B52856948; Thu, 16 Feb 2012 04:36:55 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=vIcD05Y3C4gE5p9cN12gKiBYQF8=; b=UwO3Bb JNXB3m4gcy6SCg+ydGblQRjWg9Rwtf5HCuf3Ixv1WtJb3YKppVVnJzkkGJAlaDvX hBrJ7WMcCCBdrW+3YDyXa6KiJpDQKGPWqBxgqzia4ygqIsx829rMb4URUcI/YXSQ qgQI/+xQ8gmCNbj4UENvKHhe+otAdlG6Mo1kQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=yZaneJaKF64Kx9yk0OxZvDhNLjjdPbif Gf4zaRFpN4ozZRDc3eqVvsW7TO0CIiFjzxM6BbNnXpsLZpQoc7I++0pxgo6PsFjX 61eJgii3kCY00jRw64bAzkLURJaBv7wkPeULG9wj1kvmEWtm+4QBGERUf9PIlkKu qEmZNLwVr88= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id AD0256947; Thu, 16 Feb 2012 04:36:55 -0500 (EST) Original-Received: from badger (unknown [90.164.198.39]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id 11AAB6946; Thu, 16 Feb 2012 04:36:54 -0500 (EST) In-Reply-To: (Noah Lavine's message of "Wed, 15 Feb 2012 20:29:00 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-Pobox-Relay-ID: C3862C9A-5881-11E1-BCC1-65B1DE995924-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 74.115.168.62 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:13869 Archived-At: On Thu 16 Feb 2012 02:29, Noah Lavine writes: > (let* ((x (random)) > (y x)) > (eq? x y)) > > The patch attached to this message lets peval optimize that to > > (begin (random) #t) Neat :) Note, we don't need to add extra identities to operands: they already have their gensyms. So to get the effect of this patch, you could add a clause to fold-constants: ((primcall src 'eq? (lexical _ _ x) (lexical _ _ y)) (if (eq? x y) (make-const src #t) )) This works because peval already turns it into the following, after processing the operands for value: (let ((x (random))) (eq? x x)) And all we have to do is check if the lexical is being compared against itself. Then, I was about to say: Now, while this is a valid reduction: (lambda (x) (eq? x x)) => (lambda (x) #t) This is not: (lambda (x) (eqv? x x)) =/> (lambda (x) #t) The reason is +nan.0: (eqv? +nan.0 +nan.0) => #f But.... that's wrong! (eqv? +nan.0 +nan.0) isn't specified by the R6RS, and currently we have it be #t. I guess that's good for our peval purposes! Cheers, Andy -- http://wingolog.org/