From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.lisp.guile.bugs Subject: bug#17147: Another idea Date: Mon, 12 May 2014 08:08:02 +0200 Message-ID: <871tvzwmv1.fsf@fencepost.gnu.org> References: <87k3ban107.fsf@fencepost.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1399879704 7419 80.91.229.3 (12 May 2014 07:28:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 12 May 2014 07:28:24 +0000 (UTC) To: 17147@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Mon May 12 09:28:12 2014 Return-path: Envelope-to: guile-bugs@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 1Wjkee-0003MK-P1 for guile-bugs@m.gmane.org; Mon, 12 May 2014 09:28:08 +0200 Original-Received: from localhost ([::1]:35844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wjked-0007t1-Tr for guile-bugs@m.gmane.org; Mon, 12 May 2014 03:28:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WjkeZ-0007pF-97 for bug-guile@gnu.org; Mon, 12 May 2014 03:28:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WjkeY-0004Ui-Dl for bug-guile@gnu.org; Mon, 12 May 2014 03:28:03 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42764) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WjkeY-0004Ua-Aq for bug-guile@gnu.org; Mon, 12 May 2014 03:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WjkeX-0006pN-KS for bug-guile@gnu.org; Mon, 12 May 2014 03:28:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87k3ban107.fsf@fencepost.gnu.org> Resent-From: David Kastrup Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 12 May 2014 07:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17147 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 17147-submit@debbugs.gnu.org id=B17147.139987967126223 (code B ref 17147); Mon, 12 May 2014 07:28:01 +0000 Original-Received: (at 17147) by debbugs.gnu.org; 12 May 2014 07:27:51 +0000 Original-Received: from localhost ([127.0.0.1]:60115 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WjkeM-0006oo-A4 for submit@debbugs.gnu.org; Mon, 12 May 2014 03:27:50 -0400 Original-Received: from fencepost.gnu.org ([208.118.235.10]:59071 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WjkeJ-0006og-HD for 17147@debbugs.gnu.org; Mon, 12 May 2014 03:27:48 -0400 Original-Received: from localhost ([127.0.0.1]:38145 helo=lola) by fencepost.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WjkeJ-0006gp-3y for 17147@debbugs.gnu.org; Mon, 12 May 2014 03:27:47 -0400 Original-Received: by lola (Postfix, from userid 1000) id C6FACE05FE; Mon, 12 May 2014 08:08:02 +0200 (CEST) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7452 Archived-At: Maybe the problem is just a choice of bad primitives for going to tree-il. Constructs like and/or/cond translate to deeply nested if statements. If the primitive retains the nesting level, then syntax translation can be done in one go instead of recursive matching. Example: use a primitive %cond that does the same as cond but without any of its syntax niceties. If really necessary, we can implement %cond as an unchecked procedural macro mapping to (if ...) again in a first iteration and it should still help us get out the complexity trap. Then (define-syntax and (syntax-rules () ((_) #t) ((_ x) x) ((_ x y ...) (if x (and y ...) #f)))) (define-syntax or (syntax-rules () ((_) #f) ((_ x) x) ((_ x y ...) (let ((t x)) (if t t (or y ...)))))) translates into (define-syntax and (syntax-rules () ((_) #t) ((_ x ... y) (%cond ((not x) #f) ... (#t y))))) (define-syntax or (syntax-rules () ((_) #f) ((_ x ... y) (%cond (x) ... (#t y))))) and we have no inherently quadratic behavior here since the rules are not applied recursively and the ... pattern is just matched once per construct. -- David Kastrup