As I mentioned, JavaScript doesn't have tail call elimination because of how the language is designed.
http://code.google.com/p/v8/issues/detail?id=457 On Wed, Apr 11, 2012 at 5:06 PM, Ken Woodruff <[email protected]>wrote: > > Tim Caswell <[email protected]> wrote: > >> Yes there is a slight difference under the hood, at least in the initial >> abstract syntax tree. Usually this is done in an async callback where the >> return value is going to be ignored anyway. >> > > Is there an easy (or at least not ridiculously hard) way to get node to > spit out the AST in human readable form? > > I've used the "return callback()" pattern anywhere that terseness and/or > clarity indicated (e.g. short circuits/early returns as others have > surmised), but what I'm afraid of is that it's actually causing an issue > for some async scenarios. Because the compiler doesn't know what the > callback will return, nor if returning that value from the caller will be > meaningful, I'm wondering if it keeps the otherwise unneeded method on the > stack so it can wait for the callback to return, and then return that value > back up the stack. In contrast when using approach B the compiler can know > explicitly both that the callback's return value is ignored by the caller, > and that the caller is not going to return a value, so it's safe for it to > immediately pop the caller off the stack (ala tail recursion). I have no > idea if v8 actually does anything like this, it just seems possible. > > --Ken > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
