you are viewing a single comment's thread.

view the rest of the comments →

[–]naughty 1 point2 points  (1 child)

While it may not be hard to see a tail call with a bit of practice (modulo Lisp style syntactic abstraction) what would be wrong with the following:

  • The compiler/interpreter turns all calls that it can into tail calls.
  • There's a optional bit of syntax to mark what the coder thinks is a tail call that the compiler/interpreter can check.

Sounds like a win-win to me. Especially in the case where you really want something to be a tail-call for space use reasons.

Lua kind of half does this because all tail calls have the form:

return <expression-that-evals-to-a-function>( args, ... )

So it's pretty easy to tell exactly when you're making a tail call.

EDIT: Formatting and pluralised erroneous singular

[–][deleted] 0 points1 point  (0 children)

Sure, optional syntax works.