[plt-scheme] define-for-syntax mutual recursion

From: Chongkai Zhu (czhu at cs.utah.edu)
Date: Sun May 31 23:37:53 EDT 2009

The short answer: no, you can not have mutually recursive functions 
defined via define-for-syntax.

The long answer: define them in a separate module using `define', and 
then require that module via (require (for-syntax ...))

Chongkai

Anthony Cowley wrote:
> I believe this is a variation of a past question, but I don't think it
> was completely answered...
>
> Is there any way to have mutually recursive functions defined via
> define-for-syntax?
>
> When writing run-time code, I can write
> (define (foo x) (bar x))
> (define (bar x) (+ x 2))
>
> and that's fine. But I can't write,
> (define-for-syntax (foo x) (bar x))
> (define-for-syntax (bar x) (+ x 2))
>
> In this example, I could of course re-order the definitions, but if
> they call each other then I seem to be out of luck. I would be happier
> not having to move these guys into another module, but at the very
> least I'd like to have a better understanding why such a construction
> is disallowed.
>
> Can someone shed some light on this for me?
>
> Thanks,
> Anthony
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>   



Posted on the users mailing list.