top | item 27979833

(no title)

rdaystrom | 4 years ago

I try to avoid recursion, I don't want to blow out the stack.

Personally I think it should not be used for implementation, I consider it to be a security risk. It's ok for high-level pseudocode.

discuss

order

siraben|4 years ago

This isn't true if your language does tail-call optimization[0].

> I consider it to be a security risk.

Again, non-issue if your language handles recursion properly (and in some languages like Haskell, "blowing the stack" is not a thing that happens).

[0] https://en.wikipedia.org/wiki/Tail_call#Implementation_metho...

nights192|4 years ago

I believe he's more concerned about issues where tail-calls aren't possible or attractive.

macintux|4 years ago

It depends on the language. Many good languages are designed to handle recursion safely.

For some, it’s practically the only way to loop.

waynesonfire|4 years ago

Looks like you learned something new. You now also have a guage to measure the sophistication of a programming language. Ask if it supports tail call optimization and move on if the answer is no.