Re: Structured Coding



Michael Wojcik<mwojcik@xxxxxxxxxxx> 02/06/06 11:01 AM >>>

In article <44foukF1vhs6U2@xxxxxxxxxxxxxx>, "Frank Swarbrick"
<Frank.Swarbrick@xxxxxxxxxxxxxx> writes:
Hmm, 1991 was definitely *not* "before the time of sturctured code". I
learned about structured coding when was was in junior high school in
1982
or so. This was using Pascal. I'm not even sure if Pascal has a goto
statement! (No, just kidding, I'm sure it does. We were just told to
not
use it.)

Standard Pascal does include goto, but it's deprecated, and labels
can only be integers of up to four digits (which is odd, considering
Wirth's goal of expressive and readable code). Many Pascal
implementations allow symbolic labels, but they still typically
discourage use of goto in Pascal programs.

Typically, goto is used in Pascal to escape from nested loops in the
event of an error.

Java has no goto statement proper, though it provides restricted
gotos that can only branch to certain locations (break and continue).

I like this quote from _Learning Java_:
"Multilevel break and continue statements remove the remaining justification
for the evil 'goto' statement in C/C++".

I've personally never used it, but then I haven't done a huge amount of Java
anyway. (Other than rewriting the same program over and over each time I
find a new feature. "-) )

Bought a book on C# the other day. Has a surprising amount of good stuff.
Can't recall offhand if it has multilevel break/continue statements, or
something similar.


---
Frank Swarbrick
Senior Developer/Analyst - Mainframe Applications
FirstBank Data Corporation - Lakewood, CO USA
.



Relevant Pages

  • Re: Using "break" to Break Out of Multiple Loops in One Call
    ... The main difference I see is that the syntax of the Java labeled break reinforces the idea of a structured flow. ... It's true that you can add braces to force an equivalence to a goto, but when you do so the language is giving you very loud clues about whether ... I prefer to believe that I never misuse a "goto" statement, but whether I do or not, it's my belief that the Java syntax would make it a lot more obvious to me if I'd abused the statement. ... Granted, I don't know what the Java designers were actually thinking, but I like to think that's at least part of why it's the way it is. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Would like a preprocessor.
    ... > This will probably blown your mind but I would kill for a GOTO ... whay are you writing in Java in the first place? ... > decided to try straight java first. ...
    (comp.lang.java.programmer)
  • Re: Would like a preprocessor.
    ... >> This will probably blown your mind but I would kill for a GOTO ... > I hate to tell you this, but Java actually does have a GOTO (not under ... >> I considered writing this class in JASMINE the bytecode assembler but ... >> decided to try straight java first. ...
    (comp.lang.java.programmer)
  • Re: How would you do this?
    ... But, as I've said before, I don't actually think that a "goto" statement is something to be avoided in and of itself. ... Interestingly, in Java there is no "goto" statement and the "break" and "continue" statements are specifically designed to allow for this kind of scenario. ... Similarly, the "continue" statement can continue a labeled loop block, rather than just the inner-most one. ... This forces the programmer to be explicit about falling through to the next switch, allowing the compiler to emit an error if they aren't. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Shall I move from C to Java?
    ... You have to analyze what it means to use Java ... another question is how to disable "goto", ... Need to learn how to apply control theory in your embedded system? ... "Applied Control Theory for Embedded Systems" by Tim Wescott ...
    (comp.arch.embedded)