[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: call/cc and proper tail recursion
I will probably solve the problem for SCM by creating hidden
expression types for CALL-WITH-CURRENT-CONTINUATION, EVAL, and APPLY
which are called by interpreted procedures.
Perfectly reasonable.
This is no problem for the first 2, but handling APPLY will cause
substantial duplication of code since I need a subr APPLY as well.
I don't think I understand this. Suppose %apply is the keyword of a
hidden special form that handles the restricted case of two-argument
apply. Then the general apply can be written as a procedure via
(define (apply f . args&arglist)
(define (list* restlist)
(cond ((null? restlist)
(error "Too few arguments to apply"))
((null? (cdr restlist))
(car restlist))
(else (cons (car restlist)
(list* (cdr restlist))))))
(%apply f (list* args&arglist)))
I know this is a little inefficient, but I don't see any substantial
duplication of code. Perhaps I don't understand what a subr is.
Will