See docs for local-expand. 

> On Jan 27, 2019, at 5:15 PM, Jonathan Simpson <jjsim...@gmail.com> wrote:
> 
> The code contained within lines-to-syntax-tree will run tests on an input 
> stream. My original plan was to have a function like run-query that would 
> execute the tests. So I'd need to quote the tests because they'd be executed 
> in an order defined by run-query.
> 
> I will look into making run-query a macro that expands into the code that 
> runs the tests. That may be easier in the long run anyway. Plus I'd like to 
> avoid eval in my runtime code.
> 
> I am curious if there is an easy way to expand lines-to-syntax-tree and then 
> quote it though. I'm having a hard time making the macro system do what I 
> want. I usually know what needs to be done, but quickly run into things that 
> I don't understand.
> 
> Thanks,
> Jonathan
> 
> On Sunday, January 27, 2019 at 4:08:54 PM UTC-5, Matthias Felleisen wrote:
> 
> Why is run-query not a macro and if it were, why would you quote 
> lines-to-syntax-tree? 
> 
> 
>> On Jan 27, 2019, at 4:06 PM, Jonathan Simpson <jjsi...@ <>gmail.com 
>> <http://gmail.com/>> wrote:
>> 
>> I'm having macro troubles with a DSL I'm writing. I have a macro that looks 
>> something like this:
>> 
>> (define-syntax (query stx)
>>   (let ([lines (cdr (syntax->datum stx))])
>>     (define lines-syntax-tree (parse-to-tree lines))
>>     (datum->syntax stx lines-syntax-tree)))
>> 
>> So something like 
>> 
>> (query ...linear series of s-expressions containing non-nested code...)
>> 
>> is transformed into (...hierarchical code in tree form...).
>> 
>> But what I really want is
>> 
>> (run-query '(...code in tree form...))
>> 
>> The code that I'd like quoted and passed to run-query has a number of macros 
>> I wrote that also need expanding. My problem is that all of my attempts to 
>> write a macro that results in run-query being passed a list of code to 
>> execute blocks the expansion of the passed code. Basically, I want to expand 
>> 'lines-syntax-tree' before I quote it and generate an expansion including 
>> run-query.
>> 
>> For instance, this obviously doesn't work:
>> 
>> (define-syntax (query stx)
>>   (let ([lines (cdr (syntax->datum stx))])
>>     (define lines-syntax-tree (parse-to-tree lines))
>>     (define q (list 'run-query (quote lines-syntax-tree)))
>>     (datum->syntax stx q)))
>> 
>> I'm sure I'm missing something silly, but I'd appreciate any help. I should 
>> probably read https://docs.racket-lang.org/reference/syntax-model.html 
>> <https://docs.racket-lang.org/reference/syntax-model.html>, but it is going 
>> to take me some time to grok that.
>> 
>> Thanks,
>> Jonathan
>> 
>> 
>> -- 
>> 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...@ <>googlegroups.com <http://googlegroups.com/>.
>> For more options, visit https://groups.google.com/d/optout 
>> <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 
> <mailto:racket-users+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <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