Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Automating dispatch tables

by QwertyD (Pilgrim)
on Apr 19, 2004 at 04:36 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://346194]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-03-28 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found