in reply to Easy dispatch tables.

Added a feature such that subroutines whose names start with a _ do not become part of the dispatch table.

IMHO, that's backwards. In a real-life program, the dispatch table subs will be much smaller than the number of regular subs. Having a bunch of subs with a _ before them is ugly, so their use should be minimized.

I now await a post telling me how wrong I am (:

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Re: Easy dispatch tables.
by jdporter (Paladin) on Apr 02, 2003 at 18:08 UTC
    Oh how wrong you are! ;-)

    Since the purpose of the package in which the subs live is to contain dispatch subs, it should be presumed that that is all those subs are to be used for. Allowing some subs to be exempted is a natural expediency. But it would be wrong (IMHO) to let the package (like TestPkg in the example) be any arbitrary class, or other package. Namespaces are a good way to package up a set of closely related subs, and in this case, they're closely related by virtue of being the targets of a dispatch table.

    jdporter
    The 6th Rule of Perl Club is -- There is no Rule #6.

      Ahhh, I see. You're right.

      ----
      I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
      -- Schemer

      Note: All code is untested, unless otherwise stated