Hi Matt,

In the definition of expand-ask-breed you have:

     (syntax/loc stx
        (define-syntax (ask-breed stx-inner)
          (syntax-parse stx-inner
            [(_ bodies (... ...))
             (syntax/loc stx-inner
               (for ([critter breed-vec])
                 (parameterize ([current-agent critter])
                   bodies (... ...))
                 ))]
            )))

Since we have lexical scope current-agent must be visible from here.
The fix is simple, add

     (define current-agent (make-parameter false))

to the bottom of "scopes-base.rkt" and remove it from "scopes-use.rkt".

/Jens Axel


Den ons. 12. dec. 2018 kl. 14.13 skrev Matt Jadud <m...@jadud.com>:

> Hi all,
>
> I have improved my question. In asking it, I'm trying to make sure I
> understand things so that I can ultimately ask fewer questions (about
> this). Apologies for the verbosity; it exposes more surface for confusion
> to be corrected.
>
> I read Matthew's "Macros as scopes" last night before going to bed; I
> cannot claim it was my best reading. That said, it gave me enough to sleep
> on, strip out some mess this morning, and ask a better question.
>
> https://gist.github.com/jadudm/2a1960867223773f09aef41ec551bd3f
>
> Now, I get errors that look like what I saw in the scopes paper. This
> strikes me as good.
>
> In the example code (in "scopes-use"), 'current-agent' is defined at Phase
> 0.
>
> "current-agent" in the first use, in "scopes-use"
>
> Scopes at phase 0:
> #(339342 module)
> #(339349 module scopes-use)
>
> "current-agent" as it appears in the macro expansion:
>
> Scopes at phase 0:
> #(-337432 module scopes-base)
> #(-337431 module scopes-base)
> #(-337422 module)
> #(-337421 module)
> #(339349 module scopes-use)
> #(339369 macro)
> #(339634 macro)
>
> The full error (which is probably obvious from what I've now presented) is
>
> current-agent: unbound identifier
>   context...:
>    #(-337432 module scopes-base) #(-337431 module scopes-base)
>    #(-337422 module) #(-337421 module) #(339753 macro) #(340018 macro)
>    #(340044 local) #(340045 intdef) #(340046 local) #(340047 intdef)
>    #(340049 local) #(340051 local) #(340052 intdef) #(340054 local)
>    #(340061 intdef) #(340066 local) #(340067 intdef) #(340070 local)
>    #(340071 intdef) #(340073 local) #(340074 intdef) [common scopes]
>   other binding...:
>    #(current-agent #<module-path-index='scopes-use[36514925]> 0)
>    #(339726 module) [common scopes]
>   common scopes...:
>    #(339733 module scopes-use)
>
> What I'm uncertain of is how to reconcile the scopes for the macro
> expansion. I've reached my current understanding of how friends like
> syntax/loc, and perhaps more specifically, a macro-expanding-to-a-macro,
> play with the scope expansions.
>
> It may be that I can't do what I want to do.
>
> Cheers,
> Matt
>
>
>
>
>
>
>
>
>
> On Tue, Dec 11, 2018 at 9:13 PM Matt Jadud <m...@jadud.com> wrote:
>
>> Ha! A new question!
>>
>>>
>>>>> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


-- 
-- 
Jens Axel Søgaard

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to