Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Switch/case as a dispatch table with C-style fall-through

by Roy Johnson (Monsignor)
on May 12, 2005 at 14:06 UTC ( [id://456392]=note: print w/replies, xml ) Need Help??


in reply to Re: Switch/case as a jump table with C-style fall-through
in thread Switch/case as a dispatch table with C-style fall-through

Actually, the mechanics are important. My objective in this was to address the complaints that switch is just a chain of if-elses: that all the alternatives have to be searched until a match is found. I have implemented it as a dispatch table to eliminate searching. That precludes "smart matching", though. Only strict equivalence can be done this way (ok, anything's possible, but it's not reasonable).

For more of what you're looking for, I recommend my previous posting, (Revisiting) Smart match in p5. It looks a lot like your example, though I didn't turn it into an object, and I'm not sure there's any advantage to doing so. It will be another flavor to be included in the Case package.


Caution: Contents may have been coded under pressure.
  • Comment on Re^2: Switch/case as a dispatch table with C-style fall-through

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-23 06:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found