Posts: 11,873
Threads: 474
Joined: Sep 2016
In the 70's, most microcomputer code was Basic until the advent of forth (which followed shortly thereafter)
I admit, I used it. I wanted to get things done. It was free even then! and I was poor!
I also wrote extensively in assembler (6502, 8080, 6800).
Then forth which I was passionate about.
Posts: 566
Threads: 10
Joined: Apr 2017
Apr-21-2017, 05:57 AM
(This post was last modified: Apr-21-2017, 06:18 AM by volcano63.)
(Apr-21-2017, 12:59 AM)micseydel Wrote: (Apr-20-2017, 10:41 PM)Larz60+ Wrote: Thank God No! Being a benevolent dictator for life does not make one a god!
That's why I thanked BDFL
(Apr-21-2017, 05:32 AM)Larz60+ Wrote: In the 70's, most microcomputer code was Basic until the advent of forth (which followed shortly thereafter) In 1986 I started on a Soviet clone (pirated, of course) of Wang2200. The bloody thing didn't even have procedure/functions . Then I had to translate it into Pascal on 48K clone of some Japanese microcomp. The joys of segmenting and overloading code
Test everything in a Python shell (iPython, Azure Notebook, etc.) - Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.
Posts: 470
Threads: 29
Joined: Sep 2016
(Apr-21-2017, 04:46 AM)Luke_Drillbrain Wrote: I did find it useful for certain things. One was for when I was still in the early stages of creating a loop and wanted to avoid an endless loop and a crash. I could set an integer to track the number of times something looped, and then set a place outside the loop named "JumpOut". If the integer got higher than 1,000 (or some other value), "GoTo JumpOut" would be triggered and the loop would end.
(...)
Another one was "On Error Resume Next." That was useful to keep code running while searching for errors, but I would remove it after errors were found and fixed.
I'll keep learning. I'm sure I'll come across a lot of great debugging tricks in time. Thank you so much for your useful comments.
You may want to look into python break and try/except constructs
Posts: 27
Threads: 12
Joined: Apr 2017
(Apr-21-2017, 08:24 AM)Kebap Wrote: (Apr-21-2017, 04:46 AM)Luke_Drillbrain Wrote: [snip]
You may want to look into python break and try/except constructs
I'll look those up. Thanks for the tip.
Posts: 3,458
Threads: 101
Joined: Sep 2016
(Apr-21-2017, 04:46 AM)Luke_Drillbrain Wrote: One was for when I was still in the early stages of creating a loop and wanted to avoid an endless loop and a crash. I could set an integer to track the number of times something looped, and then set a place outside the loop named "JumpOut". If the integer got higher than 1,000 (or some other value), "GoTo JumpOut" would be triggered and the loop would end.
I don't see how that'd be better than just writing a function and using return to get out of the function. It's the same thing, except with the function it's easier to see what your actual intention is.
Posts: 7,091
Threads: 122
Joined: Sep 2016
Quote:If the integer got higher than 1,000 (or some other value), "GoTo JumpOut" would be triggered and the loop would end.
To add some advice to what's alreay mention
Using Function/Class can be important to think of,
example in a function you can return out.
This can be nicer than break/continue to other stuff.
A example:
So here jump to function foo,
after foo is finish it will fall back to menu which can run again or quit( return ) out.
import time
def foo():
for i in reversed(range(5)):
time.sleep(1)
print('Running {}'.format(i))
input('Push enter to retun to menu')
def menu():
while True:
print('(1) Test someting')
print('(Q) Quit')
choice = input('Enter your choice: ').lower()
if choice == '1':
foo()
elif choice == 'q':
return
else:
print('Not a correct choice: {}'.format(choice))
if __name__ == '__main__':
menu()
Posts: 3,458
Threads: 101
Joined: Sep 2016
Apr-21-2017, 07:00 PM
(This post was last modified: Apr-21-2017, 07:01 PM by nilamo.)
Here's an article from not that long ago detailing NASA's 10 programming rules for safety: http://www.rankred.com/nasa-coding-rules/
#1 is basically never use goto.
Quote:Rule No. 1 – Simple Control Flow
Write program with very simple control flow constructs – Do not use setjmp or longjmp constructs, goto statements, and direct or indirect recursion.
Reason: Simple control flow results in improved code clarity and stronger capabilities for verification. Without recursion, there will be no cyclic function call graph, and this proves that all executions that should be bounded are in fact bounded.
Posts: 2,344
Threads: 62
Joined: Sep 2016
Not even recursion? That's interesting....
Posts: 3,458
Threads: 101
Joined: Sep 2016
That doc is probably really old. Guaranteeing something doesn't eat too much memory while careening around the surface of the moon is a little more important that just saying "it's probably going to be fine.".
Posts: 4,229
Threads: 97
Joined: Sep 2016
Yeah, the article had some good points, but it was clearly about critical systems.
|