Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: fall through switch/case in perl

by BrowserUk (Patriarch)
on Sep 07, 2004 at 02:23 UTC ( [id://388912]=note: print w/replies, xml ) Need Help??


in reply to Re: fall through switch/case in perl
in thread fall through switch/case in perl

Actually, this is just a standard switch statement,-- not Duff's device.

On the clarity argument, it's very much in the eye of the beholder whether your if cascade (or the and cascade) is clearer than the computed-goto version?

For completeness, the computed goto version works out an average of over 60% faster than either of the cascade versions, which is rather more than a few dozen clock cycles.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Replies are listed 'Best First'.
Re^3: fall through switch/case in perl
by Aristotle (Chancellor) on Sep 07, 2004 at 03:21 UTC

    That's because it doesn't test and retest conditions like the cascades do, it just computes a goto target.

    Makeshifts last the longest.

      I know that! And that's why it's a better conversion of the c switch statement.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-24 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found