News for hackers. Stuff that matters.
Re:Don't return null; use a tail call by dhx on Tuesday January 10, 2012 @07:09AM (#3446636)
Remember to keep track of the call stack in your head as you write code. The trap to avoid is to invert control and then fail to invert (return) back to the main program flow.

In the example referenced, the following call stack could be created:

  0. authenticateUser
  1. login
  2. authSucceeded
If authSucceeded continues to call other functions as if it were the new main flow of control you could end up with a very deep call stack (it's not uncommon to see software with a call stack 40 calls deep). This is why I would have preferred "authSucceeded" to be renamed as "registerUserSession" or something else that screams "this function will do a well defined bit of work and _return quickly_" rather than "this is a loosely defined event callback that may do anything".
Re:Don't return null; use a tail call by chalst on Tuesday January 10, 2012 @09:21AM (#3446993)
In the context of the OA's first sentence ("Why should an object-oriented programmer care about tail-call elimination?"), I think the author is thinking more of Scala and Ruby than Java, and there's no expectation that the tail call will return at all.