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.)
|
---|