From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6767 invoked by alias); 13 Aug 2009 17:15:03 -0000 Received: (qmail 6557 invoked by uid 22791); 13 Aug 2009 17:15:00 -0000 X-SWARE-Spam-Status: No, hits=2.3 required=5.0 tests=AWL,BAYES_00,BOTNET,NO_DNS_FOR_FROM,RDNS_DYNAMIC X-Spam-Check-By: sourceware.org Received: from adsl-64-165-110-54.sebabeach.org (HELO sspiff.sspiff.org) (64.165.110.54) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 13 Aug 2009 17:14:50 +0000 Received: from sspiff.sspiff.org (localhost.localdomain [127.0.0.1]) by sspiff.sspiff.org (8.14.2/8.14.2) with ESMTP id n7DHEm1E026285 for ; Thu, 13 Aug 2009 10:14:48 -0700 Received: (from dje@localhost) by sspiff.sspiff.org (8.14.2/8.14.2/Submit) id n7DHElXN026281; Thu, 13 Aug 2009 10:14:47 -0700 Date: Thu, 13 Aug 2009 17:15:00 -0000 Message-Id: <200908131714.n7DHElXN026281@sspiff.sspiff.org> From: Doug Evans To: cgen@sourceware.org Subject: pmacro expansion snafu? X-IsSubscribed: yes Mailing-List: contact cgen-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cgen-owner@sourceware.org X-SW-Source: 2009-q3/txt/msg00052.txt.bz2 I'm adding pmacro builtin .let*. No point in leaving it out. Anyways, I was adding another testcase for .let and found some unintuitive behaviour. guile> (pmacro-trace '(.let ((x y) (y 2)) (.list x y)) (make nil)) Pmacro expanding: (.let ((x y) (y 2)) (.list x y)) Pmacro location: standard input:11:16 Expanding: (.list x y) env: ((x . y) (y . 2)) location: standard input:11:36 result: (2 2) Pmacro result: (2 2) (2 2) guile> (pmacro-trace '(.let ((x z) (y 2)) (.list x y)) (make nil)) Pmacro expanding: (.let ((x z) (y 2)) (.list x y)) Pmacro location: standard input:14:16 Expanding: (.list x y) env: ((x . z) (y . 2)) location: standard input:14:36 result: (z 2) Pmacro result: (z 2) (z 2) guile> The problem is cgen's pmacro expansion will re-evaluate an expanded pmacro if the expansion also happens to be a pmacro. So in the first case x -> y, y is also a pmacro, so x -> y -> 2. The following is even less unintuitive (I think). guile> (pmacro-trace '(.let ((x y) (y x)) (.list x y)) (make nil)) Pmacro expanding: (.let ((x y) (y x)) (.list x y)) Pmacro location: standard input:15:16 Expanding: (.list x y) env: ((x . y) (y . x)) location: standard input:15:36 result: (x y) Pmacro result: (x y) (x y) guile> I expected to get (y x), but x -> y (which is also a pmacro, so ...) -> x and similarly y -> x -> y. I'm not sure I prefer this behaviour. Comments? I'm happy with removing cgen's quirky pmacro expansion so that (.let ((x y) (y x)) (.list x y)) -> (y x) if that's the preferred thing to do.