On Jul 18, 2015, at 5:31 PM, Matthew Flatt <[email protected]> wrote:

> At Sat, 9 May 2015 06:59:53 -0600, Matthew Flatt wrote:
>> At Thu, 16 Apr 2015 17:39:50 -0400, "Alexander D. Knauth" wrote:
>>> 
>>> On Apr 16, 2015, at 8:17 AM, Matthew Flatt <[email protected]> wrote:
>>> 
>>>> I don't think a "hygienic" reader extension works in the old expander,
>>>> either. The `lambda` produced by the `afl` or `rackjure` reader doesn't
>>>> reliably refer to the `lambda` from `racket/base`, because a local
>>>> binding for `lambda` captures the reader-produced `lambda`:
>>>> 
>>>> #lang rackjure
>>>> (let ([lambda 5])
>>>>  #λ(+ % 1)) ; => unbound `%1`
>>> 
>>> I just solved this problem for afl! (with the current macro expander)
>>> 
>> https://github.com/AlexKnauth/afl/commit/130216c2b85077aef893f7d0828d69394bceec
>> e
>>> 7
>> 
>> Yes, with the current expander, adding a fresh mark on the
>> reader-introduced identifiers makes them impossible to bind (except by
>> picking apart the form produced by `#λ...` to extract the special
>> identifiers).
>> 
>> Although that strategy doesn't work with the set-of-scopes expander,
> 
> Another idea:
> 
> Adding a fresh mark isn't sufficient, because the reader-introduced
> identifier will still have all the marks of the enclosing module, and
> so it will see any bindings created by the module.
> 
> You want the reader-introduced identifier to be *missing* a scope that
> the module has, so it won't see any of the module's bindings. It occurs
> to me now that you can arrange it to be missing a scope, because `#lang
> afl` controls the `read-syntax` call for the entire module. That
> `read-syntax` can be wrapped to add a scope, and the scope can be
> canceled for the reader-introduced identifiers in the readtable action
> for `#λ`.
> 
> 
> Specifically, starting back with the pre-set-of-scopes implementation
> of afl's "reader.rkt", add
> 
> (define current-afl-introduce (make-parameter values))
> 
> and set the new parameter in `wrap-reader` to a scope-toggling
> function:
> 
> (define (wrap-reader p)
>   (lambda args
>     (define orig-readtable (current-readtable))
>     (define introduce (make-syntax-introducer))
>     (parameterize ([current-readtable (make-afl-readtable orig-readtable)]
>                    [current-afl-introduce introduce])
>       ;; This is not quote right, because `p` could be `read`
>       ;; instead of `read-syntax`. Maybe check that the result from
>       ;; `(apply p args)` is  syntax object, and use `introduce` only
>       ;; then:
>       (introduce (apply p args)))))
> 
> and use the parameter's value in `parse` instead of creating an
> introducer there:
> 
>  (define (parse ....)
>    ....
>    (define intro (current-afl-introduce))
>    ....)

Oh! That sounds like the perfect solution!

Thanks!

I'll try that.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-dev/31D9A2E8-5548-4BFB-A2B9-1C8B07CABA74%40knauth.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to