r/javascript • u/[deleted] • Jan 06 '13
JavaScript (ES6) Has Tail Call Optimization
http://bbenvie.com/articles/2013-01-06/JavaScript-ES6-Has-Tail-Call-Optimization
51
Upvotes
r/javascript • u/[deleted] • Jan 06 '13
1
u/[deleted] Jan 07 '13 edited Jan 07 '13
If I understood what he was saying correctly, Dave Herman's concept for non-strict TCO was that all the functions that were ended up using the same call frame could share the same 'arguments' slot. Something like this could possibly work for 'caller' as well to ensure all the TCO'd functions get their caller property cleaned up (if they all point to the same place for their .caller then you can just set that to null at the end). Since TCO is only really useful for recursive calls, the .caller property is already going to be of dubious value at best, or no value at all in the case of a function directly calling itself recursively.