Questions on Proper Tail Calls
# Allen Wirfs-Brock (13 years ago)
On Mar 9, 2013, at 3:00 PM, Angus Croll wrote:
- Will proper tail calls only happen in strict mode, and if not are we ok with losing backwards compatibility re. [function].caller and [callingFunction].arguments?
Apparently yes, there is a note in the draft that we reached that conclusion at a TC39 meeting
- Will tail call behavior apply regardless of the tail call syntax? (fn(), fn.call, fn.apply)?
yes, assuming that the actual call to fn is in a tail position within the call or apply function implementations. I'll review to spec. to make sure.
- Will tail call behavior apply even when the tail call is not recursive?
yes
- If function fn has a function call in the tail position and is then bound (fn2 = fn.bind(x)), will fn2 also support proper tail calls? (I think this is only relevant if (3) is true)
yes, it is only based upon the syntactic structure of the function making the call, not it's bindings
# Angus Croll (13 years ago)
Thanks Allen, those are the answers I wanted to hear :) Seems like ES 6 proper tail calls will be a good for CPS too.
Will proper tail calls only happen in strict mode, and if not are we ok with losing backwards compatibility re. [function].caller and [ callingFunction].arguments?
Will tail call behavior apply regardless of the tail call syntax? (fn(), fn.call, fn.apply)?
Will tail call behavior apply even when the tail call is not recursive?
If function fn has a function call in the tail position and is then bound (fn2 = fn.bind(x)), will fn2 also support proper tail calls? (I think this is only relevant if (3) is true)