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: [PATCH] tree-il->scheme improvements Date: Sat, 03 Mar 2012 18:28:39 +0100 Message-ID: <871up9d260.fsf@pobox.com> References: <87hay728vi.fsf@netris.org> <87d38v28li.fsf@netris.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1330795745 4473 80.91.229.3 (3 Mar 2012 17:29:05 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 3 Mar 2012 17:29:05 +0000 (UTC) Cc: guile-devel@gnu.org To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Mar 03 18:29:02 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S3slO-0001vj-TS for guile-devel@m.gmane.org; Sat, 03 Mar 2012 18:28:59 +0100 Original-Received: from localhost ([::1]:38831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3slN-0004PA-U1 for guile-devel@m.gmane.org; Sat, 03 Mar 2012 12:28:57 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:58903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3slK-0004Os-LE for guile-devel@gnu.org; Sat, 03 Mar 2012 12:28:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S3slI-0007Mo-4A for guile-devel@gnu.org; Sat, 03 Mar 2012 12:28:54 -0500 Original-Received: from a-pb-sasl-sd.pobox.com ([74.115.168.62]:63377 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S3slH-0007Mj-Rw for guile-devel@gnu.org; Sat, 03 Mar 2012 12:28:52 -0500 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 2589980BE; Sat, 3 Mar 2012 12:28:49 -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=wEQldVREKAoYx+Oz/kRVUZcEloY=; b=NVw32/ Xf16cKCNYxEDmUUGSxWJGsH/zTedPBbebODnOmyPorl54F0zIH1howboYeA54bHg j2YIDQCkiTIYxWKJRUi2/1tQiRc3YP/5vOp8UisFzuinzuaVyC5aO00mgoQ2oyjf lqZTHWNCOUJ+8cHNDdKjTw0Hmo6SLb/46rPdE= 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=Rhmq1X1AJ+ECMtqgPfxND60CChExnP0e ajSZ1Ltctme42Hsmof139VfEvNAzUo772m3YIJjxV3IU19sYe2dZGx/K776wIg7u h74ZNKZdWWQRrsz6HozObHQaqpXNJcvDlGf2d96wFfGd8IBuIraI8iyE07s9dU1T Tgml7gNlAyU= 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 1D08D80BD; Sat, 3 Mar 2012 12:28:49 -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 5732E80BC; Sat, 3 Mar 2012 12:28:48 -0500 (EST) In-Reply-To: <87d38v28li.fsf@netris.org> (Mark H. Weaver's message of "Thu, 01 Mar 2012 18:40:41 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-Pobox-Relay-ID: 562A6BA2-6556-11E1-A6A1-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:13989 Archived-At: Hi Mark! On Fri 02 Mar 2012 00:40, Mark H Weaver writes: >> Here's a significantly refactored version of my 'tree-il->scheme' >> improvements. All look great to me, please push. Some time soon after you do it, would you mind also handling the merge to master? Only a few small points: > +(define (decompile-tree-il e env opts) > + > + (define use-derived-syntax? > + (cond ((memq #:use-derived-syntax? opts) => cadr) > + (else #t))) WDYT about (define* (do-decompile e env #:key (avoid-lambda? #t) ... #:allow-other-keys) ...) (define (decompile-tree-il e env opts) (apply do-decompile e env opts)) instead of manually handling the keywords? > + (('if ('eqv? (? atom? v) ('quote a)) #t ('eqv? v ('quote b))) > + `(memv ,v '(,a ,b))) This is not quite correct -- memv returns the rest of the list if it matches. Peval transforms memv in test context to the string of eqv? conditionals, because it knows that a list is true -- but if the source program contained (list (if (eqv? x 'a) #t (eqv? x 'b))), that's not the same as (list (memv x '(a b))). OTOH if you know you're in a test context, this is a valid transformation to make. > + (('let ((v e)) ('case v clauses ...)) > + (=> failure) I never knew this => failure feature of match :) > + ;; Repeatedly strip suffix of the form "-N", where N is a string > + ;; that could be produced by number->string given a positive > + ;; integer. In other words, the first digit of N may not be 0. > + (define compute-base-name > + (let ((digits (string->char-set "0123456789"))) > + (define (base-name-string str) > + (let* ((i (string-skip-right str digits))) > + (if (and i (< (1+ i) (string-length str)) > + (eq? #\- (string-ref str i)) > + (not (eq? #\0 (string-ref str (1+ i))))) > + (base-name-string (substring str 0 i)) > + str))) > + (lambda (sym) > + (string->symbol (base-name-string (symbol->string sym)))))) Pretty nasty, but we should continue this conversation in the other thread. Maybe it would be made more clear by procedures like `gensym?' and `gensym-base' or something. Dunno. OK, everything else looks great to me. Thanks for the opportunity to review! Andy -- http://wingolog.org/