No, it's an even better idea to do it at compile time if the list is large. The larger the list, the larger the potential savings by precomputing it once at compile time.

Yes, it is such a better idea that the following code consumes tons of resources and then dies, perhaps taking out a few other things because you've run out of some global resource:

sub rarelyUsed { my @huge; # Actually, it is usually empty if( ... ) { @huge= ('a'..'zzzz'); } elsif( ... ) { @huge= ('b'..'zzzzz'); } elsif( ... ) { @huge= ('c'..'zzzzzz'); } ... }

Because computing 3 huge lists is so much better than likely computing none of them or just computing one of them. (:

Just like it is so good that using "perl -c" can die horribly and slowly because of a typo, especially since it is supposed to be useful for looking for typos.

Now, I might consider it a good idea if the list were pre-computed the first time it gets evaluated rather than when it gets compiled. But barring such an intelligent optimization, I'd settle for having a reasonable maximum size enforced for this "optimization".

- tye        


In reply to Re^4: Syntax error makes perl hang (better) by tye
in thread Syntax error makes perl hang by VSarkiss

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.