From: Cheung, Matthew G <mgcheung@hr...>  20110614 16:38:37

One thing that has never been clear to me was whether SBCL will by default use tail recursion optimisations. I wrote a general "repeated squaring" function that takes as it's arguments a "squaring" function a "multiply" function, the base and the exponent and I wrote it tail recursively. This was to be used for both modular exponentiation and point multiplication on an elliptic curve. So can I assume SBCL will optimise by default? This question is probably more general lisp, but is it considered a better practice when writing a function using tail recursion to use a local function to do the actual tail recursion? Is it a bad idea to use an optional or keyword parameter to store the results of the intermediate calculations? In this case it seemed like it was a good idea since this function would be acting on different types of objects so I could tell it to start with 1 if I was doing modular exponentiation or the point at infinity for the elliptic curve case. Thanks. 