[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
LETREC (REC)
I'd like to defend the use of non-lambda expressions in LETREC; lambda
is only one of the function specifying forms a user may wish to invoke.
If a programmer uses a lot of higher order functions in specifying her
programs, it seems completely reasonable for her to be able to use these
forms for recursive definitions. Certainly when binding non-procedures,
the use of LETREC is ugly and ill-defined; but when binding procedures it
seems perfectly consistent and nice to have. Consider the following code:
(define (when test result)
(lambda (x) (if (test x) x (result x))))
(define (iterate n action)
(letrec ((foo (until zero? (lambda (x) (print x) (foo x)))))
(foo n)))
Here foo is being bound to a non-lambda expression one of whose arguments
is a lambda-expression which calls foo. I think this is perfectly reasonable,
as long as the recursive reference only occurs within defining forms like lambda;
and if it doesn't there's already an error to handle the case (unbound identifier).
Ken