Sujet : Re: filling area by color atack safety
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.cDate : 18. Mar 2024, 11:00:32
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <86ttl3oo5b.fsf@linuxsc.com>
References : 1 2 3 4
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
bart <
bc@freeuk.com> writes:
On 16/03/2024 13:55, Ben Bacarisse wrote:
>
Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>
Recursion make programs harder to reason about and prove correct.
>
Are you prepared to offer any evidence to support this astonishing
statement or can we just assume it's another Malcolmism?
>
You have evidence to suggest that the opposite is true?
The claim is that recursion always makes programs harder to reason
about and prove correct. It's easy to find examples that show
recursion does not always makes programs harder to reason about and
prove correct.
I personally find recursion hard work and errors much harder to
debug.
Most likely that's because you haven't had the relevant background
in learning how to program in a functional style. That matches my
own experience: it was only after learning how to write programs in
a functional style that I really started to appreciate the benefits
of using recursion, and to understand how to write and reason about
recursive programs.
It is also becomes much more important to show that will not cause
stack overflow.
In most cases it's enough to show that the stack depth never exceeds
log N for an input of size N. I use recursion quite routinely
without there being any significant danger of stack overflow. It's
a matter of learning which patterns are safe and which patterns are
potentially dangerous, and avoiding the dangerous patterns (unless
certain guarantees can be made to make them safe again).