> Okay. Show me a code where deep recursion is purposeful and useful, cannot be substituted by a for loop and the warning has to be suppressed. I'll wait.

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)

ON A META LEVEL REGARDING YOU!

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:

> If you have tested the OP code, you would have noticed that he has essentially created a loop that counts from 0 to 4 million using a function that calls itself.

°) 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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.