Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Rosetta Dispatch Table

by LanX (Saint)
on Nov 22, 2017 at 16:53 UTC ( [id://1204039]=note: print w/replies, xml ) Need Help??


in reply to Re: Rosetta Dispatch Table
in thread Rosetta Dispatch Table (Interview Question)

some annotations:
  • I would be cautious about name spaces like first:: and last:: , if you really need extra packages I'd use an extra parent one like callback::first etc
  • I'd use ->can beforehand to check if the callback is really available, to avoid an unexpected die without good notice
  • the STASH - your built in dispatch table - is a hash , just global (which leads to the first remark :)

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^3: Rosetta Dispatch Table
by tybalt89 (Monsignor) on Nov 26, 2017 at 18:45 UTC

    Is there a case that ->can is needed that is not caught by UNIVERSAL::callback ?

      Is there a case that ->can is needed that is not caught by UNIVERSAL::callback ?

      No, afaik; it rather catches too much. If some package ought to have a callback method which it hasn't due to some fubar, UNIVERSAL::callback kicks in - long faces, head-scratching. But! if someone writes a method/function for package UNIVERSAL, they should know what they are doing, and my bets are that you do.

      perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-16 18:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found