Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. GOTO, alive and well after all [modified]

GOTO, alive and well after all [modified]

Scheduled Pinned Locked Moved The Lounge
businessquestiondiscussion
25 Posts 11 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Henry Minute

    CDP1802 wrote:

    Spaghetti code

    Have you been sniffing forks again?

    Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.” I wouldn't let CG touch my Abacus! When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #21

    Only until I discovered that Gladys works here.

    "I just exchanged opinions with my boss. I went in with mine and came out with his." - me, 2011

    1 Reply Last reply
    0
    • L Lost User

      I just pulled this out of MSDN:

      using System;
      class SwitchTest
      {
      public static void Main()
      {
      Console.WriteLine("Coffee sizes: 1=Small 2=Medium 3=Large");
      Console.Write("Please enter your selection: ");
      string s = Console.ReadLine();
      int n = int.Parse(s);
      int cost = 0;
      switch(n)
      {
      case 1:
      cost += 25;
      break;
      case 2:
      cost += 25;
      goto case 1;
      case 3:
      cost += 50;
      goto case 1;
      default:
      Console.WriteLine("Invalid selection. Please select 1, 2, or 3.");
      break;
      }
      if (cost != 0)
      Console.WriteLine("Please insert {0} cents.", cost);
      Console.WriteLine("Thank you for your business.");
      }
      }

      It has been a long time since I have seen so much 'goto' in one place, especially because I also count in switch statements and 'break'. This makes the question of using goto or not look a bit academic. Edit: In the old days such code would have made much more sense. On an 8 bit CPU without any instructions for multiplication or division all kinds of crazy things were done to avoid having to multiply or divide. But those days are long over...

      "I just exchanged opinions with my boss. I went in with mine and came out with his." - me, 2011

      modified on Wednesday, March 23, 2011 4:58 AM

      S Offline
      S Offline
      Slacker007
      wrote on last edited by
      #22

      CDP1802 wrote:

      It has been a long time since I have seen so much 'goto' in one place

      GOTO statements are great when you are programming in VBA. However, I have not used it anywhere else.

      1 Reply Last reply
      0
      • L Lost User

        I just pulled this out of MSDN:

        using System;
        class SwitchTest
        {
        public static void Main()
        {
        Console.WriteLine("Coffee sizes: 1=Small 2=Medium 3=Large");
        Console.Write("Please enter your selection: ");
        string s = Console.ReadLine();
        int n = int.Parse(s);
        int cost = 0;
        switch(n)
        {
        case 1:
        cost += 25;
        break;
        case 2:
        cost += 25;
        goto case 1;
        case 3:
        cost += 50;
        goto case 1;
        default:
        Console.WriteLine("Invalid selection. Please select 1, 2, or 3.");
        break;
        }
        if (cost != 0)
        Console.WriteLine("Please insert {0} cents.", cost);
        Console.WriteLine("Thank you for your business.");
        }
        }

        It has been a long time since I have seen so much 'goto' in one place, especially because I also count in switch statements and 'break'. This makes the question of using goto or not look a bit academic. Edit: In the old days such code would have made much more sense. On an 8 bit CPU without any instructions for multiplication or division all kinds of crazy things were done to avoid having to multiply or divide. But those days are long over...

        "I just exchanged opinions with my boss. I went in with mine and came out with his." - me, 2011

        modified on Wednesday, March 23, 2011 4:58 AM

        Mike HankeyM Offline
        Mike HankeyM Offline
        Mike Hankey
        wrote on last edited by
        #23

        CDP1802 wrote:

        Edit: In the old days such code would have made much more sense. On an 8 bit CPU without any instructions for multiplication or division all kinds of crazy things were done to avoid having to multiply or divide. But those days are long over...

        We have Co-Processors now...:)

        Semper Fi http://www.hq4thmarinescomm.com[^]
        www.jaxcoder.com[^] WinHeist - Windows Electronic Inventory SysTem

        1 Reply Last reply
        0
        • R RogelioP EX DE HL

          CDP1802 wrote:

          And the Z80 had some as well, if I remember right. But they were very slow and it still was a good idea to avoid them if possible.

          The hardware multiply was missing on the Z80, programmers had to write up the routines to handle that. For those who this may interest, this is how it was done in the old days [^] :-\ -- RP

          D Offline
          D Offline
          Dan Neely
          wrote on last edited by
          #24

          No bitshift instructions on the z80?

          3x12=36 2x12=24 1x12=12 0x12=18

          1 Reply Last reply
          0
          • L Lost User

            And the Z80 had some as well, if I remember right. But they were very slow and it still was a good idea to avoid them if possible.

            "I just exchanged opinions with my boss. I went in with mine and came out with his." - me, 2011

            L Offline
            L Offline
            l a u r e n
            wrote on last edited by
            #25

            i was going to mention that too

            "mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups