"I wonder why Perl doesn't use the failure to load a method or function, because the module isn't loaded, as an opportunity to look for it and load it."

Very few languages will automatically attempt to load a class/package/module when you try to use one which isn't defined yet. Off the top of my head, I can only think of one that will — PHP, and it doesn't do so by default.

With Perl, such a feature might cause unexpected behaviour sometimes. For example:

local $Data::Dumper::Indent = 1; print Data::Dumper::Dumper($thing);

If calling Data::Dumper::Dumper() autoloaded Data::Dumper, then the autoloading would set $Data::Dumper::Indent to 2 (see the source of Dumper.pm for why) so you'd get the wrong indentation.

These kinds of bugs would probably be pretty hard to track down. Load order bugs are tricky enough to figure out already when the order modules are loaded can be seen pretty clearly in the source code; adding in autoloading would make things even worse.

While -ML is pretty handy for one-liners, having that feature enabled in anything bigger could be a nightmare.


In reply to Re^5: Perl 28 broke L: How to fix? by tobyink
in thread Perl 28 broke L: How to fix? 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.