Wrong question because - as I already told you and you already most colorfully repeated - every recursion can be written as a loop °
The purpose and usefulness is to have easily maintainable code thru elegance. The loop variant will often look very messy.
Especially when multiple recursion entries are involved, you'll end up in a spaghetti goto / next / last / redo whatever-jump mess.
Furthermore you loose the ability to have differently scoped variables in every sub-call and you'll need to cover the resulting dangers too.
The warning can be oppressed, it doesn't have to be! It's basically a post-mortem hint in case of problems with infinite loops or memory leaks.
Furthermore does Perl have an explicit mechanism to avoid repeated frames in the call-stack with recursions in the form of
Caveat: Since there is nothing on the stack you have to handle arguments in @_ and return values manually for every level then.
But with loops that's even worse! (NO elegance)
Most of what I just explained may have been wasted on you anyway, because at the moment you are only desperately trying to justify yourself.
Look, there is a saying "One can write BASIC in every language!"
And you my friend are devoted to your limited tool set from your programming paradigms from the C64 era.
But Perl is on purpose multi-paradigmatic, it allows styles from very different languages and philosophies to be mangled. Often to great success and is proud about it's TIMTOWTDI approach.
NOW if a beginner shows up asking about an aspect¹ which is NOT in your tool-set, it would be wise not to evangelize your limited world view. (Like correcting a French question with English grammar, because you know shit about this "Fresh" (sic) language)
Otherwise others in the monastery will not only think you are an idiot intellectually limited, they'll get very angry about the need to constantly correct your "wisdom". And your stubbornness trying to justify proven errors.
For example your BS claim the OP would do 4 million recursions, because you didn't even read or understand the OPs code.³
Sadly, the only 4 millions in questions here, are the down-votes you are trying to garner in the future.
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
¹) Recursions and TCO's are very produtive tools in other languages, and Perl attempts to please them too.
²) From the docs : "This is especially useful for implementing tail recursion via goto __SUB__."
³) quote:
°) and every loop can be rewritten as a goto ... But in most cases the overhead wouldn't make economic sense. This is not assembler.
In reply to Re^8: How am i doing?
by LanX
in thread How am i doing?
by Anonymous Monk
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |