From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian Price Newsgroups: gmane.lisp.guile.devel,gmane.lisp.guile.user Subject: Re: and-let* is not composable? Date: Mon, 09 Sep 2013 22:34:36 +0100 Message-ID: <87hadtof0z.fsf@Kagami.home> References: <15322456.2mtMPoYDS9@warperdoze> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1378762498 30038 80.91.229.3 (9 Sep 2013 21:34:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 9 Sep 2013 21:34:58 +0000 (UTC) Cc: guile-user@gnu.org, guile-devel@gnu.org To: Stefan Israelsson Tampe Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Sep 09 23:35:03 2013 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 1VJ96s-0003tX-Lu for guile-devel@m.gmane.org; Mon, 09 Sep 2013 23:35:02 +0200 Original-Received: from localhost ([::1]:53823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJ96s-000498-7C for guile-devel@m.gmane.org; Mon, 09 Sep 2013 17:35:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJ96h-00048w-IM for guile-devel@gnu.org; Mon, 09 Sep 2013 17:34:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VJ96d-0002zE-8p for guile-devel@gnu.org; Mon, 09 Sep 2013 17:34:51 -0400 Original-Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]:51091) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJ96c-0002yu-LZ; Mon, 09 Sep 2013 17:34:47 -0400 Original-Received: by mail-wi0-f173.google.com with SMTP id hq15so4015506wib.6 for ; Mon, 09 Sep 2013 14:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:references:mail-followup-to:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=tiYY7ke5Vm9eetyivAM7KHgYiz14W28Aoa5evwmkDKg=; b=lc/xGjF0GXvNw8U4pGTghsh/FSRjrjkicYun3kRKdWuI0740TXvqHaezGuMfqWkKF8 upczLfuDxsP+KliYVudi3Y8CqTi2rToGPb0Hx0IKabKHuXLUbrbYIbh4ubElOL1UKIKr migymApHZKckAY38p90T0qGlnrqK/CwnfYzaBI3SJTMwOh9ryGxDYa4TCpn7vWIy0Oyw jKGZLL0FGOTfdAdRwNcKi2AXmUhBJo3H/R6GHUy+K9TMuzrGjeHH/lTJDnLP++3bb4+0 4EYnHhUnIItYZW2khDI1KCQwIn2vXT053nvzrRkhbyIZdU1+axHVtd5p2fInUZDLS78B EqCA== X-Received: by 10.180.73.40 with SMTP id i8mr10101938wiv.37.1378762484752; Mon, 09 Sep 2013 14:34:44 -0700 (PDT) Original-Received: from Kagami.home (host109-157-170-145.range109-157.btcentralplus.com. [109.157.170.145]) by mx.google.com with ESMTPSA id ey2sm91651wib.5.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 09 Sep 2013 14:34:43 -0700 (PDT) Mail-Followup-To: Stefan Israelsson Tampe , guile-user@gnu.org, guile-devel@gnu.org In-Reply-To: <15322456.2mtMPoYDS9@warperdoze> (Stefan Israelsson Tampe's message of "Mon, 09 Sep 2013 22:26:54 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22d 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:16618 gmane.lisp.guile.user:10777 Archived-At: Stefan Israelsson Tampe writes: > (use-modules (srfi srfi-2)) > (use-modules (srfi srfi-1)) > > (define-curried (string-matches pattern string) > (and-let* ((match-struct (string-match pattern string)) > (count (match:count match-struct))) > (map (lambda(n)(match:substring match-struct n)) > (iota (1- count) 1)))) > > scheme@(guile-user)> (string-matches "([a-z])" "a") > $4 = ("a") > > > ,exp ((string-matches "([a-z])") "a") > $5 = ((lambda (string-871) > (let ((match-struct-876 > (string-match "([a-z])" string))) > (if match-struct-876 > (let ((count-880 (match:count match-struct-876))) > (if count-880 > (map (lambda (n-883) > (match:substring match-struct-876 n-883)) > (iota (#{1-}# count-880) 1)) > #f)) > #f))) > "a") > > And we see that string is not managed correctly. Is this a bug? I > can't understand why this is not treated as intended! The problem is one that occurs when hygienic and non-hygienic macros are mixed. Here, and-let* is the non-hygienic one. Basically, in a hygienic macro, you carry around a bunch of context to allow you to refer to the right variable names. Then defmacro comes along, strips all that away, and uses the raw symbol names. We can fix and-let* to be hygienic, that's pretty easy, but I'm not sure what you can do about this in general. It's not like you can pass in the gensymed name, because that will break the way people who for some reason still right defmacros expect them to work. Dunno, maybe I'm just missing some insight here. -- Ian Price -- shift-reset.com "Programming is like pinball. The reward for doing it well is the opportunity to do it again" - from "The Wizardy Compiled"