Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^4: Number of times I've used goto in Perl

by Anonymous Monk
on May 07, 2018 at 09:04 UTC ( [id://1214140]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Number of times I've used goto in Perl
in thread Number of times I've used goto in Perl

Just one example what you can do with switch: Duff's device.

Switch cases have the fallthrough property, so those blocks can have multiple entry edges. Besides that, switch and goto have the same problem that they can enter a scope at the middle. (For instance, C prohibits bypassing the declaration of variably modified type, e.g. int foo[n]; where n is a variable too — this is more or less the same as alloca().)

The main benefit of goto is that it can be used to set up a simple FSM without using a state variable. Which is also the main problem with goto, in case the simple turns out to be "simple".

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-26 00:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found