Oh hold on. You're drawing some very sharp lines around some issues where things aren't so clear cut.

My argument for avoiding AUTOLOAD for normal method is based on the ideas of minimal surprise, minimal complexity, and removal of potential features from future use.

You are increasing the changes that someone is going to be confused when working with your code because now the absense of a method doesn't mean it won't be handled and doesn't mean that the method isn't considered "implemented." So instead of an interface which appears one way and really is that way, you create an interface that only comes into existance when you use it. This is a kind of a trust fall - you can't see what's there to catch you and you hope it exists.

You are adding additional code at runtime that may fail or introduce some sort of bug, perhaps depending on some unexpected state of the program. When you defer method creation until runtime, if something goes wrong, you won't know this until the method is already being called, not prior or during script compilation. Also, if you write code with bugs in it (of course not you. I mean your co-worker.), maybe you've accidentally caused the creation of your method to be dependant on something that might change in a runtime. So maybe its mutable. Maybe even non-deterministic.

You've just reserved AUTOLOAD for this use and now you can't use it for something else. You didn't need to use AUTOLOAD but you did anyway. Well now that you want to use it for delegation, you either have to accomodate both your method creation and delegation in the &AUTOLOAD sub or just punt and note that now its impossible to use AUTOLOAD for delegation.

Lastly, I don't think the presence of AutoLoader.pm in the core is an argument worth making. No one really uses it anymore and I'm not sure that using it wouldn't be a mistake for most people. I swear, I just grepped my local mirror of CPAN and came up zero modules that use it. I'm re-unpacking CPAN to see if I had just grepped a partial result or something.


Update: Re-unpacking things helped. There are modules that use this. I'll even give you a list in a few minutes.

font_ft2_0.1.0 gpib-0.30 parrot_0_0_7 parrot-0.0.8 sepia vgalib ARSperl-1.82 Epeg File-LibMagic-0.82 Finance-Currency-Convert-1.04 Image-EXIF-1.00.3 Net-Divert-0.01 Net-NISplusTied-0.0 Parallel-Pvm-1.3.0 Xforms4Perl-0.8.4

In reply to Re^11: Modules for autogenerating accessor/mutator methods by diotalevi
in thread Modules for autogenerating accessor/mutator methods by srdst13

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.