[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: So, what the heck is a continuation anyway?
I had a bug in three lines of @apply where it was
failing to obey the invariant that every @-routine
finished by calling either "cont" or another @-routine.
The code should read:
(defun @apply (fn args cont)
(cond ((eq fn '+) (funcall cont (+ (first args) (second args))))
((eq fn '*) (funcall cont (* (first args) (second args))))
((eq fn 'call/cc)
(@apply (first args) (list (list 'CONTINUATION cont)) cont))
((atom fn) (funcall cont 'UNDEFINED-FUNCTION))
((eq (first fn) 'CLOSURE)
(@eval (third fn) (pairlis (second fn) args (fourth fn)) cont))
((eq (first fn) 'CONTINUATION)
(funcall (second fn) (first args)))
(t (funcall cont 'UNDEFINED-FUNCTION))))
Sorry about that. My too-simple tests had missed this.
(See what a good thing invariants are? :-)