| | Are there GOTO statements in NQC? Vadim Iosifovich Vaynerman
|
| | Hello all, I REALLY need to use a goto statement in the NQC programming project I'm doing for the RCX. Dows anybody know if such a statement extsts, and if so, what the syntax is? I know gotos are bad programming practice, but its really hard to (...) (21 years ago, 20-Nov-03, to lugnet.robotics)
|
| | |
| | | | Re: Are there GOTO statements in NQC? John Hansen
|
| | | | (...) Quoting from the NQC Guide: The goto statement forces a program to jump to the specified location. Statements in a program can be labeled by preceding them with an identifier and a colon. A goto statement then specifies the label which the (...) (21 years ago, 20-Nov-03, to lugnet.robotics)
|
| | | | |
| | | | Re: Are there GOTO statements in NQC? T. Alexander Popiel
|
| | | | (...) No, NQC does not support goto. I at one point started to add goto to the language, but abandoned the effort when I installed legOS on my brick. It's not really all that hard to add goto to the NQC language; it's a couple minor changes to the (...) (21 years ago, 20-Nov-03, to lugnet.robotics)
|
| | | | |
| | | | | | Re: Are there GOTO statements in NQC? John Hansen
|
| | | | | (...) NQC has supported the goto statement since version 2.5a3 (which was released a long time ago). (...) Nope. It's already there. John Hansen (21 years ago, 20-Nov-03, to lugnet.robotics)
|
| | | | | |
| | | | Re: Are there GOTO statements in NQC? T. Alexander Popiel
|
| | | | (...) Y'know, I really ought to check the latest version before saying these sorts of things. It appears that goto has actually been implemented since the last time I fiddled with NQC. Sorry for the misinformation. - Alex (21 years ago, 20-Nov-03, to lugnet.robotics)
|
| | | | |
| | | | Re: Are there GOTO statements in NQC? Mark Riley
|
| | | | (...) I'm probably in the minority here, but I'm going to come right out and say that goto's are not a bad thing, contrary to popular belief. In fact, I find it rather pompous when I come across admonishments in textbooks that there is no valid (...) (21 years ago, 20-Nov-03, to lugnet.robotics)
|
| | | | |
| | | | | | Re: Are there GOTO statements in NQC? Kevin L. Clague
|
| | | | | | (...) As a general rule I do not use goto's because I don't have a need for them. I've coded so many LOC in my life that the "if then else" structure of modern language was a step up from where I started. :^) The original BASIC and FORTAN had gotos (...) (21 years ago, 20-Nov-03, to lugnet.robotics)
|
| | | | | | |
| | | | | | RE: Are there GOTO statements in NQC? Ralph Hempel
|
| | | | | (...) <snipped rant> (...) And as a longtime embedded guy myself, I agree with Mark. It's the old sharp tools and dull craftsman thing. In the hands of a practiced expert, the goto can be a thing of beauty and can make the code more readable, which (...) (21 years ago, 20-Nov-03, to lugnet.robotics)
|
| | | | | |
| | | | | | | Re: Are there GOTO statements in NQC? Kevin L. Clague
|
| | | | | | (...) Ralph, I think it is a stupid rule! (...) Kevin (21 years ago, 20-Nov-03, to lugnet.robotics)
|
| | | | | | |
| | | | | | | | Re: Are there GOTO statements in NQC? Steve Baker
|
| | | | | | | (...) The thing everyone has forgotton about the "one exit point" rule is that it applies to MACHINE CODE PROGRAMMING - not high level languages. This single misunderstanding has resulted in more convoluted and illegible code than I care to (...) (21 years ago, 20-Nov-03, to lugnet.robotics)
|
| | | | | | | |
| | | | | | | | | Re: Are there GOTO statements in NQC? T. Alexander Popiel
|
| | | | | | | (...) This exact same argument can be applied to high-level languages where you dynamically allocate memory or other resources that need to be released before leaving the function. While I agree that forcing people to have only one exit point at all (...) (21 years ago, 20-Nov-03, to lugnet.robotics)
|
| | | | | | | |
| | | | | | | | | Re: Are there GOTO statements in NQC? Steve Baker
|
| | | | | | | (...) Which is why we have C++. With memory constructors and destructors, quite complex resources can be automatically and cleanly free'd up on exit from a function. ---...--- Steve Baker ---...--- HomeEmail: <sjbaker1@airmail.net> WorkEmail: (...) (21 years ago, 20-Nov-03, to lugnet.robotics)
|
| | | | | | | |
| | | | | | | | | Re: Are there GOTO statements in NQC? T. Alexander Popiel
|
| | | | | | | (...) *snicker* I'm surprised you used C as one of your example languages, then. Anyway, not all of us are so lucky as to be able to choose a language where you can hide all your cleanup code like that. As a personal issue, I find such cleanup (...) (21 years ago, 21-Nov-03, to lugnet.robotics)
|
| | | | | | | |
| | | | | | | | | Re: Are there GOTO statements in NQC? Brian B. Alano
|
| | | | | | | Don't know about C/C++, but IIRC in Java the garbage collector destroys objects not when they are out of scope, nor when their creator function exits. It destroys them when the object is no longer referenced by any threads. That is to say, if (...) (21 years ago, 21-Nov-03, to lugnet.robotics)
|
| | | | | | | |
| | | | | | | | | Re: Are there GOTO statements in NQC? Jim Choate
|
| | | | | | | | (...) The purpose of garbage collection is to remove resources from use when they are not going to be used anymore. It covers a variety of issues, some you've each touched on. I suggest as a start, Garbage Collection: Algorithms for automatic (...) (21 years ago, 21-Nov-03, to lugnet.robotics)
|
| | | | | | | | |
| | | | | | | | | Re: Are there GOTO statements in NQC? T. Alexander Popiel
|
| | | | | | | (...) Actually, this is a common misconception. In Java, there is no guarantee that memory is _ever_ reclaimed. It is perfectly permissible by the specification (and quite common in embedded applications) that garbage collection is _never_ done. At (...) (21 years ago, 21-Nov-03, to lugnet.robotics)
|
| | | | | | | |
| | | | | | | Re: Are there GOTO statements in NQC? John Hansen
|
| | | | | (...) In NQC, it is necessary to be especially careful about the use of goto as Dave writes in the NQC Guide: The goto statement should be used sparingly and cautiously. In almost every case, control structures such as if, while, and switch make a (...) (21 years ago, 20-Nov-03, to lugnet.robotics)
|
| | | | | |
| | | | Re: Are there GOTO statements in NQC? Kevin L. Clague
|
| | | | (...) I'd love to take up the personal challenge of eliminating your need for goto. Can you share your code with me? Email would be fine. Kevin (21 years ago, 20-Nov-03, to lugnet.robotics)
|
| | | | |
| | | | Re: Are there GOTO statements in NQC? Steve Baker
|
| | | | (...) Well, you'll hear people telling you: 1) Use the GOTO - it's fine. 2) Use it sparingly - it's dubious. 3) Use it only if you are totally stuck. 4) Never, ever use it - it is the work of Satan. I fall into group (4). I've been working as a (...) (21 years ago, 20-Nov-03, to lugnet.robotics)
|
| | | | |