Thanks for the response! That's not quite what I want. That will quote lambdas and applications into my redex models, but I also want it to reduce them by my reduction relation.
The link I posted discussed how to do that, but only when you write programs in the syntax of the model. Sorry for not being clear about the top-interaction. There's nothing specific about top-interaction, I'm having the same problem with module-begin. I'm trying to get them both to evaluate the terms using my redex model. The local-expand function in the article you give looks promising, but I'm still figuring out how exactly to use it, particularly with the list of expressions for module-begin. On Monday, December 31, 2018 at 8:47:49 PM UTC-8, Sorawee Porncharoenwase wrote: > > I'm a novice too, but here's my attempt to help. > > >> I'd like to use (define-syntax) to make lambda, #%app, etc. all expand >> into terms in my model. >> > > This works for me. Is this what you want? > > #lang racket/base > > (require redex) > > (define-language L > (term ::= > (TermLambda var term) > var > (TermApp term term))) > > (define-syntax-rule (lambda (x) b) > (term (TermLambda x b))) > > (default-language L) > > (lambda (y) y) > ;; => '(TermLambda y y) > > (term (substitute ,(lambda (y) y) y z)) > ;; => '(TermLambda z z) > > > >> But the problem I'm running into is that #%top-interaction applies (term) >> to its argument, which means that 'lambda' and other macros get quoted and >> not expanded. >> > > I don't totally understand how #%top-interaction is relevant here. It only > comes up when you use the REPL, and even then I think it shouldn't do > something like that. What are you trying to do in the REPL? And can't you > redefine #%top-interaction so that it doesn't do what you don't want it to > do? > > >> Is there a way to make sure that the macros are expanded *before* they >> are passed to term, so that (term) receives valid syntax trees for my >> model, instead of quoted lambdas and apps? >> > > See > https://lexi-lambda.github.io/blog/2018/10/06/macroexpand-anywhere-with-local-apply-transformer/. > > You can also just use the gist here: > https://gist.github.com/lexi-lambda/65d69043023b519694f50dfca2dc7d33 > > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

