From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Israelsson Tampe Newsgroups: gmane.lisp.guile.devel Subject: Re: syntax-local-value patch for discussion Date: Sun, 8 Jan 2012 22:28:44 +0100 Message-ID: References: <87fwfq6m5x.fsf@netris.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0015174c185477ccfe04b60af792 X-Trace: dough.gmane.org 1326058134 16228 80.91.229.12 (8 Jan 2012 21:28:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 8 Jan 2012 21:28:54 +0000 (UTC) Cc: guile-devel To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Jan 08 22:28:51 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rk0IM-00060q-Ni for guile-devel@m.gmane.org; Sun, 08 Jan 2012 22:28:51 +0100 Original-Received: from localhost ([::1]:53785 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rk0IM-0003GR-8M for guile-devel@m.gmane.org; Sun, 08 Jan 2012 16:28:50 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:58928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rk0IJ-0003FQ-82 for guile-devel@gnu.org; Sun, 08 Jan 2012 16:28:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rk0IH-0001Bu-Ue for guile-devel@gnu.org; Sun, 08 Jan 2012 16:28:47 -0500 Original-Received: from mail-ey0-f169.google.com ([209.85.215.169]:42294) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rk0IH-0001Bp-Eu for guile-devel@gnu.org; Sun, 08 Jan 2012 16:28:45 -0500 Original-Received: by eabm6 with SMTP id m6so2153850eab.0 for ; Sun, 08 Jan 2012 13:28:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Oc3ot/f9epyE8nNZo4xUDYNA+iVUe9uQzeAHSaiTLQU=; b=EjsivxWPpsg18QabdrKxxs3VTwomqU0NargbK3Dx5X5t31EN1Q6pRqhDkgzJ3uA77f ldAY0cAuxqgbfuh4fEF7jS53bOUmPV5JPnWei7Yx0dCKuZO0fpJrpSe8y4jy+luEW7Vd kTUbGVPbh4JpW/85FAdWuyoxwOiJRjH/R4rOI= Original-Received: by 10.213.114.130 with SMTP id e2mr2748031ebq.7.1326058124594; Sun, 08 Jan 2012 13:28:44 -0800 (PST) Original-Received: by 10.213.105.78 with HTTP; Sun, 8 Jan 2012 13:28:44 -0800 (PST) In-Reply-To: <87fwfq6m5x.fsf@netris.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.215.169 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:13450 Archived-At: --0015174c185477ccfe04b60af792 Content-Type: text/plain; charset=ISO-8859-1 Thanks for taking time to help with this! On Sun, Jan 8, 2012 at 8:15 PM, Mark H Weaver wrote: > Hi Stefan, > > Stefan Israelsson Tampe writes: > > diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm > > index e522f54..70463a5 100644 > > --- a/module/ice-9/psyntax.scm > > +++ b/module/ice-9/psyntax.scm > > @@ -155,6 +155,10 @@ > > (eval-when (compile) > > (set-current-module (resolve-module '(guile)))) > > > > +(define *macro-lookup* (make-fluid)) > > +(fluid-set! *macro-lookup* > > + (lambda x (error "not in a macro evaluation context"))) > > + > > (let () > > (define-syntax define-expansion-constructors > > (lambda (x) > > @@ -1304,8 +1308,12 @@ > > (syntax-violation #f "encountered raw symbol in > macro output" > > (source-wrap e w (wrap-subst w) > mod) x)) > > (else (decorate-source x s))))) > > - (rebuild-macro-output (p (source-wrap e (anti-mark w) s mod)) > > - (new-mark)))) > > + (with-fluids ((*macro-lookup* > > + (lambda (e) (lookup (id-var-name e w) > > + r mod)))) > > + > > + (rebuild-macro-output (p (source-wrap e (anti-mark w) s mod)) > > + (new-mark))))) > > > > (define expand-body > > ;; In processing the forms of the body, we create a new, empty > wrap. > > This doesn't look quite right to me. > > At this one point only, where a macro is expanded, you capture the > lexical environment (r w mod) in your fluid. This is the lexical > environment that you use to lookup plain symbols later passed to > `syntax-binding-info'. > I first tought that the semantic meant that to get the macro binding for a symbol in the stored lexical environment. and acording to the racket doc, in a supplied context or the context of the expansion (hence the use of the fluid) But reading your mail the context mentioned in the doc is probably related to syntax-parameters. Hence I will try to folllow your suggestions to refine the approach. /Stefan --0015174c185477ccfe04b60af792 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks for taking time to help with this!

On Sun, Jan 8, 2012 at 8:15 PM, Mark H Weaver <mhw@netris.org>= wrote:
Hi Stefan,

Stefan Israelsson Tampe <stefan.itampe@gmail.com> writes:
> diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm=
> index e522f54..70463a5 100644
> --- a/module/ice-9/psyntax.scm
> +++ b/module/ice-9/psyntax.scm
> @@ -155,6 +155,10 @@
> =A0(eval-when (compile)
> =A0 =A0(set-current-module (resolve-module '(guile))))
>
> +(define *macro-lookup* (make-fluid))
> +(fluid-set! *macro-lookup*
> + =A0 =A0 =A0 =A0 =A0 =A0(lambda x (error "not in a macro evaluat= ion context")))
> +
> =A0(let ()
> =A0 =A0(define-syntax define-expansion-constructors
> =A0 =A0 =A0(lambda (x)
> @@ -1304,8 +1308,12 @@
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (syntax-violation #f "enc= ountered raw symbol in macro output"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 (source-wrap e w (wrap-subst w) mod) x))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(else (decorate-source x s)))))=
> - =A0 =A0 =A0 =A0(rebuild-macro-output (p (source-wrap e (anti-mark w)= s mod))
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(new-mark= ))))
> + =A0 =A0 =A0 =A0(with-fluids ((*macro-lookup*
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (lambda (e) (lookup (id-= var-name e w)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 r mod))))
> +
> + =A0 =A0 =A0 =A0 =A0(rebuild-macro-output (p (source-wrap e (anti-mar= k w) s mod))
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(new-= mark)))))
>
> =A0 =A0 =A0(define expand-body
> =A0 =A0 =A0 =A0;; In processing the forms of the body, we create a new= , empty wrap.

This doesn't look quite right to me.

At this one point only, where a macro is expanded, you capture the
lexical environment (r w mod) in your fluid. =A0This is the lexical
environment that you use to lookup plain symbols later passed to
`syntax-binding-info'.=A0

I first tought that = the semantic meant that to get the macro binding for a symbol in the stored= lexical
environment. and acording to the racket doc, in a supplied cont= ext or the context of the expansion (hence
the use of the fluid) But reading your mail the context mentioned in the do= c is probably related to
syntax-parameters. Hence I will try to folllow = your suggestions to refine the approach.

/Stefan
--0015174c185477ccfe04b60af792--