[plt-scheme] define-for-syntax mutual recursion
Thanks, Carl, I'll give that a shot. Is there any explanation for why
this is necessary, though? It seems natural to expect the define-for-
syntax
form to work like define.
Anthony
On May 31, 2009, at 11:48 PM, Carl Eastlund <carl.eastlund at gmail.com>
wrote:
> On Sun, May 31, 2009 at 11:44 PM, Anthony Cowley <acowley at seas.upenn.edu
> > wrote:
>> On Sun, May 31, 2009 at 11:38 PM, Carl Eastlund<carl.eastlund at gmail.com
>> > wrote:
>>> You can use define-values-for-syntax:
>>>
>>> (define-values-for-syntax [is-even? is-odd?]
>>> (values
>>> (lambda (x) (if (zero? x) #t (is-odd? (sub1 x))))
>>> (lambda (x) (if (zero? x) #f (is-even? (sub1 x))))))
>>
>> Ah, thanks, Carl. I usually try to avoid this form since it separates
>> the name from the lambda by such a long distance, but this seems to
>> be
>> the quick fix for my current troubles.
>>
>> Anthony
>
> (define-syntax-rule (define-mutual-for-syntax [(name . args) .
> body] ...)
> (define-values-for-syntax [name ...]
> (values (lambda args . body) ...)))
>
> (define-mutual-for-syntax
> [(is-even? x) (if (zero? x) #t (is-odd? (sub1 x)))]
> [(is-odd? x) (if (zero? x) #f (is-even? (sub1 x)))])
>
> --
> Carl Eastlund