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. Where Is IntelliSense For "goto" statements?

Where Is IntelliSense For "goto" statements?

Scheduled Pinned Locked Moved The Lounge
visual-studiocsharptutorialquestion
58 Posts 28 Posters 13 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.
  • P PIEBALDconsult

    What language?

    R Offline
    R Offline
    Richard Blythe
    wrote on last edited by
    #17

    C# Have you noticed that no one has even remotely answered the original question?

    The mind is like a parachute. It doesn’t work unless it’s open.

    P 1 Reply Last reply
    0
    • L Luc Pattyn

      a goto in some decompilation output does not prove there was a goto in the original source; it could be the decompiler did not recognize the original (looping) construct. In the end, every construct that changes the program flow is bound to get translated in an elementary jump/goto/branch/call/return instruction. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

      R Offline
      R Offline
      Richard Blythe
      wrote on last edited by
      #18

      Point well taken.

      The mind is like a parachute. It doesn’t work unless it’s open.

      1 Reply Last reply
      0
      • D Dr Walt Fair PE

        We could always repeat until the next topic comes up.

        CQ de W5ALT

        Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

        R Offline
        R Offline
        RichardM1
        wrote on last edited by
        #19

        I'm taking exception with this whole line of reasoning.

        Opacity, the new Transparency.

        T 1 Reply Last reply
        0
        • R RichardM1

          I'm taking exception with this whole line of reasoning.

          Opacity, the new Transparency.

          T Offline
          T Offline
          TheyCallMeMrJames
          wrote on last edited by
          #20

          You could always try to override the topic.

          They Call me Mister James

          R 1 Reply Last reply
          0
          • T TheyCallMeMrJames

            You could always try to override the topic.

            They Call me Mister James

            R Offline
            R Offline
            RichardM1
            wrote on last edited by
            #21

            Please, just take it to another thread!

            Opacity, the new Transparency.

            A A 2 Replies Last reply
            0
            • L Luc Pattyn

              a goto in some decompilation output does not prove there was a goto in the original source; it could be the decompiler did not recognize the original (looping) construct. In the end, every construct that changes the program flow is bound to get translated in an elementary jump/goto/branch/call/return instruction. :)

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

              R Offline
              R Offline
              RichardM1
              wrote on last edited by
              #22

              Luc Pattyn wrote:

              translated in an elementary jump/goto/branch/call/return instruction

              Good for the goose, good for the gander. There are instances where nothing else works, but they tend to be when you are implementing threads (not using them, implementing them). And when you are using VB. Wait, you are a VB programmer, why do you want to get rid of the only errorarrow in your quiver? Damn, that was a good line. :sigh: Except I wrote it after I read Dave Kreskowiak's signature, not yours, so it doesn't apply here. Well, I hope someone else can re-use it later. :)

              Opacity, the new Transparency.

              1 Reply Last reply
              0
              • R Richard Blythe

                I don't use the: "goto" statement very often but I have started using it more frequently. Does anyone know why Visual Studio does not implement IntelliSense for goto statements? For example: // VS code editor does not show IntelliSense with //available "Label_" when entering this goto statement if (condition == true) goto Label_ExitCode; //... Label_ExitCode: //...

                The mind is like a parachute. It doesn’t work unless it’s open.

                M Offline
                M Offline
                Mycroft Holmes
                wrote on last edited by
                #23

                Richard Blythe wrote:

                Does anyone know why Visual Studio does not implement IntelliSense for goto statements?

                Probably so newbies will not use it until they get to the point of understanding it's consequences. I took the lemonade in the 90s that discredited that particular set of structures and have not used a goto in more that 12 years. I do not regret the decision!

                Never underestimate the power of human stupidity RAH

                P 1 Reply Last reply
                0
                • R Richard Blythe

                  C# Have you noticed that no one has even remotely answered the original question?

                  The mind is like a parachute. It doesn’t work unless it’s open.

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #24

                  I was waiting for someone else to make a serious answer. I suspect it's because a label doesn't exist like a function or variable does. They don't allocate memory. Are they in the name/symbol table (or whatever)?

                  1 Reply Last reply
                  0
                  • M Mycroft Holmes

                    Richard Blythe wrote:

                    Does anyone know why Visual Studio does not implement IntelliSense for goto statements?

                    Probably so newbies will not use it until they get to the point of understanding it's consequences. I took the lemonade in the 90s that discredited that particular set of structures and have not used a goto in more that 12 years. I do not regret the decision!

                    Never underestimate the power of human stupidity RAH

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #25

                    It's more a language concern; modern languages have more robust sets of flow control constructs and so don't require it. I still have to use it DCL.

                    M 1 Reply Last reply
                    0
                    • P PIEBALDconsult

                      It's more a language concern; modern languages have more robust sets of flow control constructs and so don't require it. I still have to use it DCL.

                      M Offline
                      M Offline
                      Mycroft Holmes
                      wrote on last edited by
                      #26

                      PIEBALDconsult wrote:

                      modern languages have more robust sets of flow control

                      Absolutely, I can't understand why it has not been, what's that word, deprecated. For the life of me I can't think of a reason for it to be there, I wonder if GoSub is still in there as well.

                      Never underestimate the power of human stupidity RAH

                      R E 2 Replies Last reply
                      0
                      • M Mycroft Holmes

                        PIEBALDconsult wrote:

                        modern languages have more robust sets of flow control

                        Absolutely, I can't understand why it has not been, what's that word, deprecated. For the life of me I can't think of a reason for it to be there, I wonder if GoSub is still in there as well.

                        Never underestimate the power of human stupidity RAH

                        R Offline
                        R Offline
                        Richard Blythe
                        wrote on last edited by
                        #27

                        Somewhere in this thread, it has been assumed that I'm a VB guy. I write C#, read C#, eat C#. (Okay, maybe not that die hard) :) I've been trying to dig up a good example of me using the "goto" statement. However, in most cases, I would probably get a pile of contradictory replys. I guess I should take the nearest exit on this "goto" road. :laugh:

                        The mind is like a parachute. It doesn’t work unless it’s open.

                        L N M 3 Replies Last reply
                        0
                        • R Richard Blythe

                          Somewhere in this thread, it has been assumed that I'm a VB guy. I write C#, read C#, eat C#. (Okay, maybe not that die hard) :) I've been trying to dig up a good example of me using the "goto" statement. However, in most cases, I would probably get a pile of contradictory replys. I guess I should take the nearest exit on this "goto" road. :laugh:

                          The mind is like a parachute. It doesn’t work unless it’s open.

                          L Offline
                          L Offline
                          Leslie Sanford
                          wrote on last edited by
                          #28

                          Richard Blythe wrote:

                          I've been trying to dig up a good example of me using the "goto" statement.

                          I haven't used goto's, but my understanding is that they can be helpful in error handling, e.g. goto HandleError. It allows you to write code after such goto statements in such a way that it can assume that no error has occurred, thus simplifying things. One could argue that this is what exceptions are for. But the same reasoning that says that goto's are bad would seem to apply to exceptions, maybe even more so. Using goto to jump ahead within a function to execute some error handling code would seem less confusing than throwing the control flow completely out of the current context to who knows where.

                          T 1 Reply Last reply
                          0
                          • R Richard Blythe

                            Thanks for your informative post. :laugh:

                            The mind is like a parachute. It doesn’t work unless it’s open.

                            N Offline
                            N Offline
                            Nish Nishant
                            wrote on last edited by
                            #29

                            Ctrl-Space will drop down all available keywords/symbols (but it won't show just the labels). Maybe they never considered this a big enough priority since not many people use gotos these days.

                            Regards, Nish


                            Blog: blog.voidnish.com Most recent article: An MVVM friendly approach to adding system menu entries in a WPF application

                            1 Reply Last reply
                            0
                            • R Richard Blythe

                              Somewhere in this thread, it has been assumed that I'm a VB guy. I write C#, read C#, eat C#. (Okay, maybe not that die hard) :) I've been trying to dig up a good example of me using the "goto" statement. However, in most cases, I would probably get a pile of contradictory replys. I guess I should take the nearest exit on this "goto" road. :laugh:

                              The mind is like a parachute. It doesn’t work unless it’s open.

                              N Offline
                              N Offline
                              Nish Nishant
                              wrote on last edited by
                              #30

                              Richard Blythe wrote:

                              I've been trying to dig up a good example of me using the "goto" statement. However, in most cases, I would probably get a pile of contradictory replys.

                              Here's one case where "some people" think it's okay:

                              private static void Foo(int x)
                              {
                              Console.WriteLine(String.Concat("Option: ", x));

                              switch (x)
                              {
                                  case 0:
                                      Console.WriteLine("English");
                                      goto case 1;
                              
                                  case 1:
                                      Console.WriteLine("Spanish");
                                      break;
                              
                                  default:
                                      Console.WriteLine("English");
                                      break;
                              }
                              
                              Console.WriteLine();
                              

                              }

                              And here's the refactored goto-less version:

                              private static void AltFoo(int x)
                              {
                              Console.WriteLine(String.Concat("Option: ", x));

                              switch (x)
                              {
                                  case 0:
                                      DisplayEnglish();
                                      DisplaySpanish();                
                                      break;
                              
                                  case 1:
                                      DisplaySpanish();                
                                      break;
                              
                                  default:
                                      DisplayEnglish();
                                      break;
                              }
                              
                              Console.WriteLine();
                              

                              }

                              private static void DisplaySpanish()
                              {
                              Console.WriteLine("Spanish");
                              }

                              private static void DisplayEnglish()
                              {
                              Console.WriteLine("English");
                              }

                              Regards, Nish


                              Blog: blog.voidnish.com Most recent article: An MVVM friendly approach to adding system menu entries in a WPF application

                              C 1 Reply Last reply
                              0
                              • R Richard Blythe

                                Somewhere in this thread, it has been assumed that I'm a VB guy. I write C#, read C#, eat C#. (Okay, maybe not that die hard) :) I've been trying to dig up a good example of me using the "goto" statement. However, in most cases, I would probably get a pile of contradictory replys. I guess I should take the nearest exit on this "goto" road. :laugh:

                                The mind is like a parachute. It doesn’t work unless it’s open.

                                M Offline
                                M Offline
                                Mycroft Holmes
                                wrote on last edited by
                                #31

                                Richard Blythe wrote:

                                Somewhere in this thread, it has been assumed that I'm a VB guy

                                I think goto started life in basic which morphed into VB so the assumption seems reasonable to me. There are a lot of us around that code in both VB and C#, most seem to have a preference to C# but VB is so very common. I moved our teams to C# because all the best examples are in that flavour (and I needed to learn something new/different about then anyway).

                                Never underestimate the power of human stupidity RAH

                                R 1 Reply Last reply
                                0
                                • R Richard Blythe

                                  I don't use the: "goto" statement very often but I have started using it more frequently. Does anyone know why Visual Studio does not implement IntelliSense for goto statements? For example: // VS code editor does not show IntelliSense with //available "Label_" when entering this goto statement if (condition == true) goto Label_ExitCode; //... Label_ExitCode: //...

                                  The mind is like a parachute. It doesn’t work unless it’s open.

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

                                  I can see no reason, it's not particularly hard to get the set of valid target labels for a given goto

                                  1 Reply Last reply
                                  0
                                  • R Richard Blythe

                                    I don't use the: "goto" statement very often but I have started using it more frequently. Does anyone know why Visual Studio does not implement IntelliSense for goto statements? For example: // VS code editor does not show IntelliSense with //available "Label_" when entering this goto statement if (condition == true) goto Label_ExitCode; //... Label_ExitCode: //...

                                    The mind is like a parachute. It doesn’t work unless it’s open.

                                    U Offline
                                    U Offline
                                    urbane tiger
                                    wrote on last edited by
                                    #33

                                    I'd like to know why C# doesn't have a comefrom, with or without Intellisense

                                    "we shall patiently bear the trials that fate imposes on us" -- Anton Chekhov Uncle Vanya

                                    G 1 Reply Last reply
                                    0
                                    • M Mycroft Holmes

                                      Richard Blythe wrote:

                                      Somewhere in this thread, it has been assumed that I'm a VB guy

                                      I think goto started life in basic which morphed into VB so the assumption seems reasonable to me. There are a lot of us around that code in both VB and C#, most seem to have a preference to C# but VB is so very common. I moved our teams to C# because all the best examples are in that flavour (and I needed to learn something new/different about then anyway).

                                      Never underestimate the power of human stupidity RAH

                                      R Offline
                                      R Offline
                                      Richard Blythe
                                      wrote on last edited by
                                      #34

                                      If a developer plans to work heavily with MS Office projects, I would encourage them to learn VB. Other than that, I would strongly advise C#. I realize that most of the compiled funtionality between VB and C# is the same but by learning C#, you have a leg up on several languages: Java, JavaScript, C++, etc.

                                      Mycroft Holmes wrote:

                                      all the best examples are in that flavour

                                      Your right, and C# hasn't become popular by accident.

                                      The mind is like a parachute. It doesn’t work unless it’s open.

                                      1 Reply Last reply
                                      0
                                      • U urbane tiger

                                        I'd like to know why C# doesn't have a comefrom, with or without Intellisense

                                        "we shall patiently bear the trials that fate imposes on us" -- Anton Chekhov Uncle Vanya

                                        G Offline
                                        G Offline
                                        glennPattonWork3
                                        wrote on last edited by
                                        #35

                                        Hi, Not a proper softy (I'm a hardware guy who programs on occasion) I have used a goto only in RTOS situations where if the program counter/accumlator goes beyond a certain point it will make a whole in the wall as it goes beyond reach. I was one of the spagetti basic guys who gave the goto a bad rep. It's just a way of moving around the memory so thats why the .NET compilers use it (or a jmp or jump instruction) it's only when people who didn't know what it was or how to use it got involved did it get a bad reputation. Glenn (let the abuse begin!)

                                        R 1 Reply Last reply
                                        0
                                        • N Nish Nishant

                                          Richard Blythe wrote:

                                          I've been trying to dig up a good example of me using the "goto" statement. However, in most cases, I would probably get a pile of contradictory replys.

                                          Here's one case where "some people" think it's okay:

                                          private static void Foo(int x)
                                          {
                                          Console.WriteLine(String.Concat("Option: ", x));

                                          switch (x)
                                          {
                                              case 0:
                                                  Console.WriteLine("English");
                                                  goto case 1;
                                          
                                              case 1:
                                                  Console.WriteLine("Spanish");
                                                  break;
                                          
                                              default:
                                                  Console.WriteLine("English");
                                                  break;
                                          }
                                          
                                          Console.WriteLine();
                                          

                                          }

                                          And here's the refactored goto-less version:

                                          private static void AltFoo(int x)
                                          {
                                          Console.WriteLine(String.Concat("Option: ", x));

                                          switch (x)
                                          {
                                              case 0:
                                                  DisplayEnglish();
                                                  DisplaySpanish();                
                                                  break;
                                          
                                              case 1:
                                                  DisplaySpanish();                
                                                  break;
                                          
                                              default:
                                                  DisplayEnglish();
                                                  break;
                                          }
                                          
                                          Console.WriteLine();
                                          

                                          }

                                          private static void DisplaySpanish()
                                          {
                                          Console.WriteLine("Spanish");
                                          }

                                          private static void DisplayEnglish()
                                          {
                                          Console.WriteLine("English");
                                          }

                                          Regards, Nish


                                          Blog: blog.voidnish.com Most recent article: An MVVM friendly approach to adding system menu entries in a WPF application

                                          C Offline
                                          C Offline
                                          cgh1977
                                          wrote on last edited by
                                          #36

                                          Sorry.. I see the case you are trying to make, but in this specific case there is a simpler goto-less construct:

                                          private static void AltFoo(int x)
                                          {
                                          Console.WriteLine(String.Concat("Option: ", x));

                                          if (x != 1)
                                          {
                                              Console.WriteLine("English");
                                          }
                                          if (x == 0 || x == 1)
                                              Console.WriteLine("Spanish");
                                          }
                                          
                                          Console.WriteLine();
                                          

                                          }

                                          I expect your response will be something along the line of 'extend the example to more complex cases and the if-then approach becomes unwieldy'. Granted. Of the three examples (mine and your two), your second example is the best solution. It is considerably easier to understand and is more maintainable. Suppose the specification adds support for three other languages: French, German, and Italian. The goto version becomes impossible (without a lot of convoluted spaghetti code), but this code is very clear:

                                          private static void AltFoo(int x)
                                          {
                                          Console.WriteLine(String.Concat("Option: ", x));

                                          switch (x)
                                          {
                                              case 0:
                                                  DisplayEnglish();
                                                  DisplaySpanish();
                                                  DisplayGerman();
                                                  DisplayItalian();
                                                  break;
                                          
                                              case 1:
                                                  DisplaySpanish();
                                                  break;
                                          
                                              case 2:
                                                  DisplayGerman();
                                                  break;
                                          
                                              case 3:
                                                  DisplayItalian();
                                                  break;
                                          
                                              default:
                                                  DisplayEnglish();
                                                  break;
                                          }
                                          
                                          Console.WriteLine();
                                          

                                          }

                                          private static void DisplayItalian()
                                          {
                                          Console.WriteLine("Italian");
                                          }

                                          private static void DisplayGerman()
                                          {
                                          Console.WriteLine("German");
                                          }

                                          private static void DisplaySpanish()
                                          {
                                          Console.WriteLine("Spanish");
                                          }

                                          private static void DisplayEnglish()
                                          {
                                          Console.WriteLine("English");
                                          }

                                          N 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