Re:Curious C++ Lambda Examples: Recursion, constexpr, Contai...
by mxz3000 on Sunday August 14, 2022 @05:11AM
(#32457737)
In production code, you'd generally avoid recursion to avoid stack overflows.
Given in most languages you can't enforce tail call optimisation, it's risky to use unbounded recursion.
Re:Curious C++ Lambda Examples: Recursion, constexpr, Contai...
by CoastalCoder on Sunday August 14, 2022 @10:53AM
(#32459750)
I suspect this guideline varies a lot by industry or by target hardware.
The last time I worked on a project with that rule was about 23 years ago, and that was on a 32-bit system.
Obviously in a non-functional language, you can do these things without recursion by using your own stack rather than the runtime function-call stack. But sometimes it's nice to have the stack provided for you. That also plays well with C++ runtime exception propagation.