Comment by xonix

Comment by xonix 16 hours ago

6 replies

Re: TCO

Does the language give any guarantee that TCO was applied? In other words can it give you an error that the recursion is not of tail call form? Because I imagine a probability of writing a recursion and relying on it being TCO-optimized, where it's not. I would prefer if a language had some form of explicit TCO modifier for a function. Is there any language that has this?

ZiiS 15 hours ago

At least in Lua then the rule is simply 'last thing a function dose' this is unambiguous. `return f()` is always a tail call and `return f() + 1` never is.

  • [removed] 12 hours ago
    [deleted]
draven 15 hours ago

Scala has the @tailrec annotation which will raise a warning if the function can’t be TCO’d