From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] psyntax: custom ellipses using 'with-ellipsis' or R7RS syntax-rules Date: Fri, 10 Jan 2014 12:08:47 -0500 Message-ID: <877ga7wyqo.fsf@netris.org> References: <87bo0del31.fsf@netris.org> <871u0i8zvx.fsf@gnu.org> <8761puxmim.fsf@netris.org> <87ppo2w5zb.fsf@gnu.org> <87fvowwy8r.fsf@netris.org> <87bnzkour2.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1389373895 31695 80.91.229.3 (10 Jan 2014 17:11:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 10 Jan 2014 17:11:35 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Jan 10 18:11:39 2014 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 1W1fcQ-0001kC-Od for guile-devel@m.gmane.org; Fri, 10 Jan 2014 18:11:38 +0100 Original-Received: from localhost ([::1]:57945 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1fcQ-0001F1-A1 for guile-devel@m.gmane.org; Fri, 10 Jan 2014 12:11:38 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50806) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1fcH-0001Ep-29 for guile-devel@gnu.org; Fri, 10 Jan 2014 12:11:34 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W1fcB-0006qK-NY for guile-devel@gnu.org; Fri, 10 Jan 2014 12:11:28 -0500 Original-Received: from world.peace.net ([96.39.62.75]:43163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W1fcB-0006pP-JZ; Fri, 10 Jan 2014 12:11:23 -0500 Original-Received: from c-98-217-64-74.hsd1.ma.comcast.net ([98.217.64.74] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1W1fbq-0005Zl-9G; Fri, 10 Jan 2014 12:11:02 -0500 In-Reply-To: <87bnzkour2.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Fri, 10 Jan 2014 14:02:09 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 96.39.62.75 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:16797 Archived-At: Hi Ludovic, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Mark H Weaver skribis: > >> ludo@gnu.org (Ludovic Court=C3=A8s) writes: > > [...] > >>> Actually my question was more about the ellipsis escaping form >>> (... ...). It is affected by =E2=80=98with-ellipsis=E2=80=99, right? >> >> Yes, so the following works: >> >> (define-syntax define-inline >> (with-ellipsis --- >> (syntax-rules () >> ((_ (name parms ---) exp ---) >> (define-syntax name >> (with-ellipsis (--- ---) >> (syntax-rules () >> ((_ args (--- ---)) >> ((lambda (parms ---) exp ---) >> args (--- ---)))))))))) > > > Sorry I wasn=E2=80=99t clear. Does this work: > > (define-syntax define-inline > (with-ellipsis --- > (syntax-rules () > ((_ (name parms ---) exp ---) > (define-syntax name > (with-ellipsis --- ; <- note here! > (syntax-rules () > ((_ args (--- ---)) > ((lambda (parms ---) exp ---) > args (--- ---)))))))))) > > IOW, does the escaping syntax adjust to the current ellipsis? Yes, the escaping syntax does adjust to the current ellipsis, but no, your example won't work. It differs from the working code I gave in just one respect: you passed "---" as the first operand to 'with-ellipsis', whereas I passed "(--- ---)". Since you chose the same ellipsis identifier for both the inner and outer macros, you need to escape the ellipsis passed to the inner 'with-ellipsis', just as you need to escape any ellipsis that you want to remain present in the generated code. Remember that macros are expanded from the outside in. When (define-inline (foo a b c) (list a b c)) is expanded, at that point the entire inner 'define-syntax' form is just a template, and it has no understanding of the inner syntax forms. Therefore, it will interpret your inner "with-ellipsis ---" as meaning that 'with-ellipsis' should be a pattern variable. You need to write "with-ellipsis (--- ---)" instead, which will expand into "with-ellipsis ---" in the generated code. >> Needless to say, the whole point of custom ellipses is to avoid having >> to ever escape ellipses, but you can still do it. > > Yes of course; that=E2=80=99s an academic question to satisfy my curiosit= y. [...] >> I ended up making the effect of 'with-ellipsis' propagate into syntax >> definition forms, since the semantics seem simpler to me. > > OK. > > So does that mean that in the example above the second =E2=80=98with-elli= psis=E2=80=99 > can now be omitted, or is it limited to =E2=80=98let...-syntax=E2=80=99? No, it's not limited to 'let...-syntax'. The effect of 'with-ellipsis' propagates into 'define-syntax' forms well. However, you still need the second 'with-ellipsis' in your example, because the effect of 'with-ellipsis' does not affect the ellipsis of the generated code. If you want one macro to generate another macro definition that uses a custom ellipsis, you must include 'with-ellipsis' in the generated code. Regards, Mark