Last active
December 11, 2015 08:49
-
-
Save aaronfrost/4576086 to your computer and use it in GitHub Desktop.
Question for Dave Herman.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function foo(){ | |
var temp = bar(); | |
return temp; | |
} | |
/* | |
Is this a tail call? the call to bar is not actually in tail position, however | |
it is the last instruction to execute before the return expression. Let me know. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No, it's not a tail call. When people explain tail calls as "the last thing a function does" they're explaining the intuition but being imprecise. Proper tail calls are really about describing a syntactic category of positions known as tail position, and guaranteeing that the implementation uses a bounded amount of space for calls in tail position. Since, as you say, the call to
bar
in this example is not in tail position, it is not a tail call.Dave