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).
Caution: Contents may have been coded under pressure.
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.
|
---|
In Section
Cool Uses for Perl