(Responded to Joey offlist, but for others interested, here's a more detailed 
reply)

The "(#%expression (let-values () (let-values (((ws1) (#%expression ..." wrapper
is a bunch of internal Racket stuff.
For simple #lang's, I've been able to just ignore it, although I'm sure it's got
some important binding information in general that someone else can comment on.

In #lang Cur, I've got a similar process to Joey's language: fully expand and
execute, then reflect back to the surface syntax.
To deal with this `let-values` wrapping, I use the following syntax-class,
`in-let-values`, to throw out the `let-values` wrappers and extract the body of
the expression that I care about.
  
https://github.com/wilbowma/cur/blob/b9a278c8105da2c7a848ff7886151858c84af62a/cur-lib/cur/curnel/racket-impl/stxutils.rkt#L81

I can then reflect the fully expanded syntax back into surface syntax
(syntax->datum can suffice for simple Redex languages).
For example, the Cur elaboration function is below.
It calls `local-expand`, uses `in-let-values` throw out the let-values wrappers,
and returned the body expression:
  
https://github.com/wilbowma/cur/blob/246c8e06e245e6e09bbc471c84d69a9654ac2b0e/cur-lib/cur/curnel/racket-impl/type-check.rkt#L88

--
William J. Bowman

On Thu, Jan 17, 2019 at 11:50:41AM -0800, Joey Eremondi wrote:
> As part of my ongoing attempt to turn my Redex model into a #lang, I'm 
> wondering, is there a way to fully expand and evaluate a syntax object at 
> compile-time? I'm trying to get compile-time typechecking working.
> 
> Here's what I have:
> 
>  * My Redex model uses names like TermLam, TermApp etc.
>  * I've defined lambda and #%app so that the user can write normal programs 
> that are translated into Redex terms.
>  * I've done (require (for/syntax redex/reduction-semantics 
> "my-redex-model.rkt")), so that I have access to my Redex model at compile 
> time
> 
> When the user writes a term (using lambda and #%app macros), I need to take 
> the syntax object 
> 
> I'd tried using local-expand and syntax->datum,  but I think it's expanding 
> too far, i.e. it's giving "(#%expression (let-values () (let-values (((ws1) 
> (#%expression ..." redex doesn't know how to interpret as a term.
> 
> Is there a way to do this? Or am I trying to push redex farther than 
> intended?
> 
> Thanks!
> 
> -- 
> 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.

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

Reply via email to