Re: OT: The REAL RIddle of DO LOOPS Solved



I assume you mean "decrement" or "STEP -1".
No I did actually mean increment until the value reaches it's maximum
and then wraps round when it overflows (e.g. for an unsigned byte 255+1
= 0, for a 16 bit signed integer +32762+1 = -32763) and continues
incrementing until the target value is reached.

In fact that is my contention that any BASIC should KNOW in the
statement FOR n = A to B
whether the STEP is +1 or -1, without requiring the explicit
statement of STEP or STEP SGN(B-A).

I think we will have to agree to disagree. I think any BASIC should
KNOW in the statement FOR N = A TO B that if B<A and I haven't
explicitely told it how to step then I might have made a programming
error. Imagine the A and B concerned is counting a value that must
clearly increment, such as investment months in a loop generating
values that are a function of compound interest earnt.

I also stand by the more basic principle that programming languages are
there to allow me to instruct a computer to follow an unambiguous
sequence of operations. If there is any ambiguity in what should be
done then that's poor programming on my part and I would ideally want
the language to highlight my error rather than take a guess.

If BASIC did throw an error when Luis' program was given the sort of
values that kicked off this discussion then there would have been no
need for this thread. The program would have required modification to
cope with the additional possible inputs that (presumably) were not
considered by the original programmer and the code for the modified
program would have explicitely specified how such values should be
handled.

.



Relevant Pages

  • Re: How to determine odd or even number?
    ... > increment count variables based on %2, ... Take shop instead of programming. ... wouldn't want my house wired by a guy who can't figure out modulus operator! ...
    (comp.lang.java.programmer)
  • Re: Cargo Cult Membership
    ... his knowledge of programming seems suspect: ... Those who write Cargo cult programs explain their useless code as ... line with comments such as "increment i by 1". ... commenting code has no influence on the final program. ...
    (talk.origins)
  • Re: Cargo Cult Membership
    ... his knowledge of programming seems suspect: ... Those who write Cargo cult programs explain their useless code as ... line with comments such as "increment i by 1". ... commenting code has no influence on the final program. ...
    (talk.origins)
  • Re: Cargo Cult Membership
    ... his knowledge of programming seems suspect: ... Those who write Cargo cult programs explain their useless code as ... line with comments such as "increment i by 1". ... MSDN and including it in your program. ...
    (talk.origins)
  • Re: Good Dungeon Mapping e-Tool?
    ... for that, it doesn't extend well to other resources, and isn't ... of late to add it to every programming environment that gets created. ... explicit dispose call even though the GC would clean up the purely ... whether the interface that you're using points to a disposable object ...
    (rec.games.frp.dnd)