Re: [racket-users] Pattern: reusing the same name in macro-generated definitions

2019-04-05 Thread Matthew Butterick
> On Apr 5, 2019, at 3:23 AM, zeRusski wrote: > > Now about that error in the docs: I was skeptical, but I think you're right: "More generally, we can define binding based on subsets: A reference’s binding is found as one whose set of scopes is a subset of the reference’s own scopes (in addi

Re: [racket-users] Pattern: reusing the same name in macro-generated definitions

2019-04-05 Thread zeRusski
A simple model to keep in your head: > Each macro keeps a count, i, of how many times it has been applied. > Each time a the output of a macro contains a definition of name not > present in the input it appends _i to the name. > Ha, I get it. That's a good little heuristic. I'm keeping it

Re: [racket-users] Pattern: reusing the same name in macro-generated definitions

2019-04-05 Thread Jens Axel Søgaard
Yes! fre. 5. apr. 2019 kl. 13.52 skrev Hendrik Boom : > On Fri, Apr 05, 2019 at 01:35:37PM +0200, Jens Axel Søgaard wrote: > > Den tor. 4. apr. 2019 kl. 21.58 skrev zeRusski >: > > > > (define-simple-macro (define-foo (name:id formal:id ...) body:expr ...) > > >> (begin > > >> (define (foo

Re: [racket-users] Pattern: reusing the same name in macro-generated definitions

2019-04-05 Thread Hendrik Boom
On Fri, Apr 05, 2019 at 01:35:37PM +0200, Jens Axel Søgaard wrote: > Den tor. 4. apr. 2019 kl. 21.58 skrev zeRusski : > > (define-simple-macro (define-foo (name:id formal:id ...) body:expr ...) > >> (begin > >> (define (foo-impl formal ...) body ...) > >> (define-syntax (name stx) > >>

Re: [racket-users] Pattern: reusing the same name in macro-generated definitions

2019-04-05 Thread Jens Axel Søgaard
Den tor. 4. apr. 2019 kl. 21.58 skrev zeRusski : (define-simple-macro (define-foo (name:id formal:id ...) body:expr ...) >> (begin >> (define (foo-impl formal ...) body ...) >> (define-syntax (name stx) >> (syntax-parse stx >> [(_ . args) #'(foo-impl . args)] >> [_:

Re: [racket-users] Pattern: reusing the same name in macro-generated definitions

2019-04-05 Thread zeRusski
> If I understand correctly, the fourth paragraph here is relevant? > > > https://docs.racket-lang.org/reference/syntax-model.html#%28part._transformer-model%29 > > > I dreaded someone pointing me there. I read it a year ago, took a lot of head scratching and careful reading before I convi

Re: [racket-users] Pattern: reusing the same name in macro-generated definitions

2019-04-04 Thread Greg Hendershott
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 `na

Re: [racket-users] Pattern: reusing the same name in macro-generated definitions

2019-04-04 Thread zeRusski
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

Re: [racket-users] Pattern: reusing the same name in macro-generated definitions

2019-04-04 Thread Ben Greenman
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

[racket-users] Pattern: reusing the same name in macro-generated definitions

2019-04-04 Thread zeRusski
While reading *rackunit* source I stumbled on a pattern that I can't figure out. Why the heck does it work? Condensed to its essence it amounts to introducing indirection with a macro-generated define: #lang racket > (require (for-syntax syntax/parse) > syntax/parse/define) > (defi