If I understand correctly, the fourth paragraph here is relevant?

  
https://docs.racket-lang.org/reference/syntax-model.html#%28part._transformer-model%29

So, `foo-impl` is a binding introduced by the macro and gets that
macro invocation's fresh macro-introduction scope.

Whereas for example `name` is syntax coming from outside the macro,
and doing `(define-foo (blerg ___) ___)` twice would be an error due
to redefining `blerg`.

On Thu, Apr 4, 2019 at 4:45 PM zeRusski <vladilen.ko...@gmail.com> wrote:
>
> I know in principle but on occasion I fail to understand the implications.  
> Let me think aloud. I don't have to be perfectly accurate, maybe just about 
> right. Hygiene here means that every symbol there e.g. arguments my macro 
> receives carry their "environment" with them. There exists some oracle which 
> can tell when two symbols refer to the same thing probably by checking 
> environments somehow. Since I just typed that foo-impl there in the template 
> it must be getting some fresh tag or "environment" attached to it to avoid 
> capturing something with the same name defined at the macro call site, right? 
> Ok. How the define before foo-impl is special then? We both know the "define" 
> I mean. Or is the newly attached "environment" is in fact not empty and comes 
> enriched with a bunch of Racket stuff? How do I reason when its safe to just 
> type a name and when it isn't? In fact, here. I just defined a foo-impl 
> outside. If I now remove the macro-defined foo-impl the code will still work 
> correctly and grab the outer definition. So define inside a template refers 
> to the usual define, but foo-impl doesn't? Why?
>
> (define (foo-impl op a b) (op a b))
>
> (define-simple-macro (define-foo (name:id formal:id ...) body:expr ...)
>      ... same ...
>
> (define-foo (bar op a b) (op a b))
> (define-foo (baz op a b) (op a b))
> (bar + 1 2)
> ;; => 3
>
>
>
> On Thursday, 4 April 2019 21:02:58 UTC+1, Ben Greenman wrote:
>>
>> Racket's macros are hygienic. They'll gensym for you.
>
> --
> 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.

-- 
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