Tail recursive function in 'labels' not acting tail recursive
Hello,
I’m wondering about the tail recursion reduction properties of LW. I have the following function:
(labels ((helper (l n)
(values (if (cdr l)
(let ((item-2 (car l)))
(if (>= (ajenda-item-time item)
(ajenda-item-time item-2))
(helper (cdr l) (incf n))
(setf (cdr l) (cons item (cdr l)))))
(setf (cdr l) (list item)))
n)))
but when I run it I get a popup about a stack overflow on large lists. I know how to eliminate the stack overflow popup by increasing the stack size, but this looks tail recursive to me. I have tried to declaim (speed 3) with no results. Am I missing something to get proper tail recursion optimization out of the LW compiler?
—
Burton Samograd