Having written a "do everything" object like this myself (WebPerl::JSObject), I can confirm that there are some methods you won't be able to override, and some you probably shouldn't (e.g. those from UNIVERSAL). IMHO, you probably should just bite the bullet and document for your users that not all method calls will be AUTOLOADed. Either that, or reconsider using AUTOLOAD in the first place - for example, I wrote IPC::Run3::Shell because the AUTOLOADing behavior of Shell is a bit too dangerous, or I wrote Util::H2O to provide protection against typos when accessing hashes. OTOH, for a dynamic object, a purely hashref- and arrayref-based interface might make sense from a user's point of view.

However, methods like FETCH and FIRSTKEY shouldn't be a problem (WebPerl example, requires a modern browser). You haven't shown us an SSCCE, but I suspect that perhaps you're using a single class to handle the AUTOLOAD and the tied interfaces as well, which I would recommend against; you should use separate classes for each of the tied types.

Also, a word of warning: it's possible to make an interface "too clever" such that it gets so complex that only the author will understand it ("It's so simple! Just press Ctrl+Shift+\ while clicking the middle mouse button!"). Consider as one counterexample the method-based API of Hash::Ordered, which some would consider that a quite clean API. Of course an API like the one you are designing could be made quite clean as well if you don't overload it too much, I don't know since you haven't described the whole thing, but it is something to keep in mind.

Minor edits.


In reply to Re: AUTOLOAD vs. DESTROY... by haukex
in thread AUTOLOAD vs. DESTROY... by coreybrenner

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.