On Wed, Nov 2, 2016 at 2:53 PM, Dan Liebgold
<dan_liebg...@naughtydog.com> wrote:
> On Wednesday, November 2, 2016 at 5:25:03 AM UTC-7, Jay McCarthy wrote:
>>
>> Another approach is to do something like:
>>
>>
>> (define-syntax (myfor stx)
>>   (syntax-parse stx
>>     [(_ (clause:for-clause ...) body:expr)
>>      (with-syntax ([(the-ast ...) (attribute clause.ast)])
>>        #''(the-ast ... body))]))
>>
>
> This seems promising, but I'm not sure how to access the contents of 
> structure referred to by the-ast (or clause.ast)... it seems like the struct 
> bindings need to be accessible at both syntax and runtime phases?

(attribute clause.ast) is the list of structures. So you could do
something like:

(filter guard? (attribute clause.ast)) and then do something different
in each one

>>
>> As for examples, one of my favorite ones is this regular expression compiler 
>> implemented as a syntax-class where each attribute is kind of like a 
>> "method" that is called on the sub-components during the compilation:
>>
>>
>> https://github.com/jeapostrophe/automata/blob/master/automata-lib/re-compile.rkt
>>
>
> This is interesting, and seems to point the way to implementing more logic in 
> the syntax phase.

I think of it as the syntax attribute being like one of the many
denotations of the syntax and the main macro pulls them together

> I'm wondering if this is how the examples from the docs would be best 
> completed...
>
> --
> 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.



-- 
Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io

           "Wherefore, be not weary in well-doing,
      for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
                          - D&C 64:33

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