[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
No internal DEFINE-SYNTAX?
> In the R4RS macro appendix it says:
>
> Furthermore, there is no DEFINE-SYNTAX analogue of the internal
> definitions described in section 5.2.2.
>
> Is this because it leads to an contradiction? Couldn't internal
> DEFINE-SYNTAXs be transformed into a LETREC-SYNTAX?
It doesn't lead to any more semantic difficulties than internal
defines. Furthermore, a group of internal define-syntax forms can be
converted into a letrec-syntax expression. However, a group of
internal definitions including both "define" and "define-syntax" forms
cannot be similarly converted. Consider the following definition of
factorial:
(define factorial
(lambda (n)
(define f (lambda (x) (if (= x 0) 1 (* x (g x)))))
(define-syntax g (syntax-rules () ((g y) (f (- y 1)))))
(f 10)))
This cannot be converted into a letrec-syntax for g with a letrec for f
inside; nor can it be converted into a letrec for f with a
letrec-syntax for g inside. In the former case, f would not be visible
within g, and in the latter, g would not be visible within f.