guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: syntax-local-value patch for discussion


From: Stefan Israelsson Tampe
Subject: Re: syntax-local-value patch for discussion
Date: Sun, 8 Jan 2012 22:28:44 +0100

Thanks for taking time to help with this!

On Sun, Jan 8, 2012 at 8:15 PM, Mark H Weaver <address@hidden> wrote:
Hi Stefan,

Stefan Israelsson Tampe <address@hidden> 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]