|Re: what's wrong with this program? / STO error|
Message #18 Posted by Mark Edmonds on 2 Sept 2009, 5:29 p.m.,
in response to message #17 by Don Shepherd
I may not have put my point over as clearly as I wanted!
My first paragraph was a purist view - thou shalt not do this.
My second paragraph was being more realistic and admitting that it is done.
However, I still think it is very important to write "elegant" code. All my comments were in relation to UserRPL and not regular step programming where anything goes (the thread being about a 48 program).
I consider step programming to be a bit like doing 8 bit assembler with a fancy CPU and quite low level. In those circumstances, you do whatever you need to do to get the job done - there are no rules.
UserRPL on the other hand is a distinct high-level language which like it or not, imposes structures on the program that you have to follow.
Anyway, as UserRPL doesn't allow loop-breaking by keyword, this is all a bit moot but I still maintain that using the correct loop structure is very important (but not mandatory!).
Hi Mark. I'm not so sure that the formal requirements inherent in structured programming apply--or should apply--to calculator programming. Good grief, if it's a mainframe program and other programmers may have to make changes to it in the future, then structured programming is appropriate, along with verbose and meaningful comments. But in calculator programming, or programs we write ourselves for ourselves, an emphasis on structured programming may be a bit misplaced.
I once wrote an article on the ultimate in un-structured programming for the 17b solver, in which I described how to exit a loop early by doing a divide by 0. For calculators, just do what works for you.
After all, how could one expect structured programming on a calculator like the 12c, with one of the keys labelled "GOTO"?