Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Need help converting!!!

by james28909 (Deacon)
on Nov 16, 2015 at 02:18 UTC ( [id://1147769]=note: print w/replies, xml ) Need Help??


in reply to Re: Need help converting!!!
in thread Need help converting!!!

honestly, i dont really understand the whole "goto" thing or a legit reason to use it. in my mind though, it is a failure of the programmer to even understand their own logic, which makes them use such a shortcut, especially when there are plenty of other things you can do.

Replies are listed 'Best First'.
Re^3: Need help converting!!! (goto)
by LanX (Saint) on Nov 16, 2015 at 02:48 UTC
    "goto" is older.

    Many highlevel constructs are just gotos in disguise and their documentation still contains expressions like "go to beginning of loop"

    A language agnostic algorithm description might still say "go to" (like in this case)

    And because most use cases have been abstracted away doesn't mean there are no legit applications left for goto

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

      well, i was just trying to understand it honestly, because in all the CRAZY shit i have had perl do , it has paid off, and i havent ever used "goto". but just because i have never used it, doesnt meant there isnt a reason to use it i reckon. im just a novice anyway, but i do appreciate the user-bility of perl. its like the "engrish" of the computing language :)

      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)

        > 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 ???)

        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.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^3: Need help converting!!!
by dsheroh (Monsignor) on Nov 16, 2015 at 08:35 UTC
    Given that the OP was presenting a relatively-plain-English description of an algorithm, rather than actual code (or even pseudocode!), I'm rather confident that "goto 2" was intended to mean "repeat the above process, starting at step 2", not that he used or expected to use an actual goto statement.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-06-15 23:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    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.