~??

Member
  • Content count

    1
  • Joined

  • Last visited

Community Reputation

103 Neutral

About ~??

  • Rank
    Newbie
  1. C++ - Is Goto a Good Practice?

    As long as a language has [font=courier new,courier,monospace]goto[/font], it isn't intrinsically bad to use it. It is possible to use it either in a right or in a wrong way. The thing is that as a language has a higher level than others, it is in general spontaneously easier and natural to avoid using [font=courier new,courier,monospace]goto[/font]. __________________________________________________ __________________________________________________ __________________________________________________ I am currently mainly an x86 Assembly language programmer but I can program a bit of C, Pascal, and a good amount of JavaScript and PHP, so I can tell you that in languages higher than Assembly (including C) I rarely use [font=courier new,courier,monospace]goto[/font]. It might seem paradoxical but Assembly language has helped me no end to find ways to program very elegantly and concisely without using [font=courier new,courier,monospace]goto[/font], or excessive nested [font=courier new,courier,monospace]if[/font]s or nested function calls. Now, I find myself all the time converting higher-level code to Assembly by hand. In that case, you can see that down to the bare metal level all of your loops, conditional code and the like, [b]must[/b] be converted to conditional Assembly instructions that work exactly like [font=courier new,courier,monospace]goto[/font], and in general it can't be avoided at that point (which by the way is by no means an obsolete environment but just the very essence of a machine). I also find myself converting Assembly code to higher-level code, and in this case I must find ways to do it efficiently. I almost never need to use [font=courier new,courier,monospace]goto[/font] when doing this. In other words, knowing how to use [font=courier new,courier,monospace]goto[/font] properly is necessary, not to be abused and not to be ignored either (specially if you know and want to use Assembly language, among other things, to work a little bit in designing or understanding compiler-like programs that generate Assembly code). If you use it too much in a high-level language, chances are that you are still in a very incipient level of knowledge for a proper implementation of your logic when you could use syntax elements better suited for what you want to achieve in that language (e.g., using [font=courier new,courier,monospace]goto[/font] for no special reason when you could have used a [font=courier new,courier,monospace]while[/font] loop that maybe you just didn't know how to use).