in reply to Re^2: AUTOLOAD cascade
in thread AUTOLOAD cascade

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.

Replies are listed 'Best First'.
Re^4: AUTOLOAD cascade
by ysth (Canon) on Oct 13, 2004 at 18:43 UTC
    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.

Re^4: AUTOLOAD cascade
by BrowserUk (Patriarch) on Oct 13, 2004 at 18:12 UTC

    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
      The difference between all of those is that mucking about with the symbol table has special significance to the interpreter. Of course, this is why we do it. But, I would argue that greater care and thought needs to be put into symbol-table mucking than, say, your own hash-based dispatch table. You have a greater capacity to introduce subtle bugs that you would with a dispatch table, mixins, and the like.

      Now, inheritance, symbol importation, mixins, and localising globals are different in my mind because there is an interface for doing this. The code behind the interface is tested, so you're not building it from scratch. Remember the lesson of Netscape.

      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.