Skip to content

Comment on Google's Common Lisp style-guideparent

Comments

Thanks for that Scott, I've never heard of TCE -- learn something every day reading HN.

Just did a quick comparison (SBCL) between the above and the textbook version:

(defun sum (list) (if (null list) 0 (+ (car list) (sum (cdr list)))))

This version quickly dumped Heap Exhaustion. The LABELS version does not, and can handle summation over lists much faster as well.

What does this mean? TCE only applies applies to local calls, therefore we should never write a "raw" recursive function? (which is a tad more elegant, imo). I haven't delved into TCOs deep enough to understand, but I had hoped that a smart compiler would be able to optimize the latter?

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.