in reply to AUTOLOAD cascade

It sounds to me like you should eschew AUTOLOAD and just generate your methods as soon as your program is able to do so. If that is during compilation, generate them during BEGIN. If that is at runtime, perhaps after accessing a database, generate them when you connect.

Unless there is a good reason, methods shouldn't be created at their moment of invocation. Its just bad practice.

Replies are listed 'Best First'.
Re^2: AUTOLOAD cascade
by BrowserUk (Patriarch) on Oct 13, 2004 at 17:33 UTC
    ...methods shouldn't be created at their moment of invocation. Its just bad practice

    Why?

    It would only happen at the moment of first invocation, subsequent invocations would just be normal method calls.

    Conversely, if the method is never called, it is never created, which might be a good thing?


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
      Until the code required to do it is so convoluted that you have to post on Perlmonks just to fix the first bug you found, having no idea what other bugs are lurking in the wings.

      Fooling around with the symbol table is akin to messing with dragons. You don't want to do that because you are crunchy and taste good with ketchup.

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

        Declaring a variable is just as much fooling around with the symbol table just as much as using a sub declaration and AUTOLOAD (which is to say, not very much).

        But using AUTOLOAD without sub declarations in a situation where there is inheritance going on is indeed foolish.

        I find that a strange attitude. Symbol tables are essentially, hashes. And subs/methods are essentially a hash-based dispatch table. And it seems to me that dispatch tables have recently been lauded here.

        Come to that, you could consider inheritance, mixins, importing symbols, localising globals all as "fooling with the symbol table.

        Equally, plenty of people post to Perlmonks the first (and second and third...) time they use regex, or references and many other Perl techniques and constructs. Should we avoid all of these because they are sometimes difficult to get to grips with at first?


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail
        "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon