J
Jens Müller
Hi,
I am currently reading Douglas Crockford's "JavaScript: The Good Parts".
On page 35, it says:
"Some languages offer the /tail recursion optimization/. This means that
if a function returns the result of invoking itself recursively, then
the invocation is replaced with a loop, which can significantly speed
things up. Unfortunately, JavaScript does not currently provide tail
recursion optimization. Functions that recurse very deeply can fail by
exhausting the return stack."
I'm not quite sure what the author's point is here. IMO, an optimization
is not a property of the language, but of a particular implementation.
IMO, the same holds for implementation of nested function calls using a
return stack.
Does the author mean that existing implementations do not offer this
optimization, or is there more about the argument, i.e., does JavaScript
has some properties that make tail recursion optimization difficult or
impossible?
- Jens
I am currently reading Douglas Crockford's "JavaScript: The Good Parts".
On page 35, it says:
"Some languages offer the /tail recursion optimization/. This means that
if a function returns the result of invoking itself recursively, then
the invocation is replaced with a loop, which can significantly speed
things up. Unfortunately, JavaScript does not currently provide tail
recursion optimization. Functions that recurse very deeply can fail by
exhausting the return stack."
I'm not quite sure what the author's point is here. IMO, an optimization
is not a property of the language, but of a particular implementation.
IMO, the same holds for implementation of nested function calls using a
return stack.
Does the author mean that existing implementations do not offer this
optimization, or is there more about the argument, i.e., does JavaScript
has some properties that make tail recursion optimization difficult or
impossible?
- Jens