Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re^4: Need help converting!!! (goto)

by Preceptor (Deacon)
on Nov 16, 2015 at 17:29 UTC ( [id://1147821]=note: print w/replies, xml ) Need Help??

in reply to Re^3: Need help converting!!! (goto)
in thread Need help converting!!!

Indeed - processors don't loop, they just jmp - which is extremely similar to the goto that is considered harmful. Fortunately, we have higher level constructs available. (Although even then, I'll often last out of a loop)

Replies are listed 'Best First'.
Re^5: Need help converting!!! (goto)
by LanX (Saint) on Nov 16, 2015 at 17:53 UTC
    > I'll often last out of a loop

    Exactly: last , next , redo , ... are just gotos with restrictions.

    Throwing exceptions is also a kind of goto.

    I remember a talk where TheDamian showed code which was not better written without goto.

    Knowing that fire is dangerous led to new methods for heating, cooking and constructing lamps.

    But this doesn't mean lighters and matches have no use left and must be strictly forbidden.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

    PS: next EXPR since 5.18? Wow I missed that one ... (??? o.O ???)

Re^5: Need help converting!!! (goto)
by afoken (Chancellor) on Nov 17, 2015 at 05:38 UTC
    Indeed - processors don't loop, they just jmp

    Right in general, wrong in detail. The x86 family has the rep, repz and repnz prefixes since at least 1978 that each implement an implicit while loop in combination with "string" instructions cmps, ins, lods, movs, outs, scas, stos, without any jumps in assembly code.


    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-06-20 02:01 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.