Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Automating dispatch tables

by QwertyD (Pilgrim)
on Apr 19, 2004 at 04:36 UTC ( #346194=note: print w/replies, xml ) Need Help??


in reply to Automating dispatch tables

Hm... interesting idea. The main point seems to be unifying the sub declarations and the dispatch table. In the first example, you declare subs, then create a dispatch table for them, then dispatch. In the second, you declare subs, and essentially use the symbol table as a dispatch table.

You could also do the opposite, which is to create the subs as part of the dispatch table:

my %dispatch = ( foo => sub {}, bar => sub {}, baz => sub {}, qux => sub {}, ); if( exists $dispatch{ $method } ) { $dispatch{$method}->(); } );

Or am I missing the point?
(It's entirely possible. I should be asleep right now.)


Once it's Turing complete, everything else is just syntactic sugar.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://346194]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2020-05-29 01:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (166 votes). Check out past polls.

    Notices?