[racket] does render-term or term->pict work in a metafunction?
2012/3/14 Stephen Chang <stchang at ccs.neu.edu>:
>> What you have written suggests that
>> you're writing a metafunction that returns a pict, which would mean
>> that the terms in your language are being represented as Racket-level
>> picts (instead of the usual Racket-level sexpressions).
>
> Yes, that's what I'm trying to do. I want to convert an arbitrary term
> to a pict, to use in slideshow.
I think you probably want to use a racket macro, not a redex metafunction.
>
>> Anyways, if you want to render a term, you have to use lw->pict and
>> to-lw. It is more complex than it needs to be.
>
> I don't think this would work either, since to-lw is still a macro.
>
> Something like:
>
> (define-metafunction L
> [(x->pict x) ,(lw->pict (language-nts L) (to-lw x))])
>
> still gives a pict of x for (term (x->pict y)).
>
>
> To get what I want, I figured out I can do:
>
> (define-metafunction L
> [(x->pict x) ,(text (symbol->string (term x)))])
That's not going to work well for very many arguments to x->pict.
Robby