Re: OT: The REAL RIddle of DO LOOPS Solved




Richard Atkins wrote:
By logical extension, if the initial value is GREATER than
the STOPPING value, the default step size should be -1,
to be consistent with the "+1" convention, in context.

[Not the] ... ARBITRARY convention adopted by the new
ANSI -- to the detriment of violating sound LOGIC and
consistency.

When encountering the instruction FOR X = A TO B where A > B then
surely the 'logical' and 'consistent' thing for a programming language
from the 60s would be to set X to A and then increment until the value
wraps round to B.

I assume you mean "decrement" or "STEP -1".


Facetiousness aside: When encountering ambiguity, rather than guess
what I meant using 'logical extension' (which in some contexts may not
be logical, depending on what A and B actually represent) I would
rather programming languages have simple, unconditional behaviours and
respond to ambiguity by throwing an error, requiring me to be more
explicit. After all the ambiguity may as easily have arisen from a
design or programming error.

You haven't exhibited ANY ambiguity. STEP (Sgn) (B-A) would
have worked if that's an allowable explicit statement for STEP.


In particular, since BASIC has an optional STEP statement that would
allow me to explicitely implement conditional 'reverse' stepping (e.g.
STEP SIGN(B-A)) then it shouldn't be guessing that this is what I
wanted even though I didn't ask for it. Anything less is sloppy
language design that encourages sloppy programming.

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).

You should read the rest of the discussion in alt.lang.basic where
this thread has already doubled the total posts in that group prior
to yesterday (15), and the thread itself has run to 30, making the
current total of 45 posts for May.

-- Bob.

.



Relevant Pages

  • Re: OT: The REAL RIddle of DO LOOPS Solved
    ... to be consistent with the "+1" convention, in context. ... surely the 'logical' and 'consistent' thing for a programming language ... When encountering ambiguity, ...
    (sci.stat.math)
  • Re: OT: The REAL RIddle of DO LOOPS Solved
    ... to be consistent with the "+1" convention, in context. ... surely the 'logical' and 'consistent' thing for a programming language ... When encountering ambiguity, ...
    (sci.stat.math)
  • Re: both upseting now, Satam and Woodrow armed the constant covenants beneath steady warrant
    ... station is too explicit for Wayne to part it. ... Don't even try to widen home while you're formulating other than a ... then we mentally supplement Murad and Ayub's narrow ... She will comment about if Feyd's influence isn't consistent. ...
    (sci.crypt)
  • Re: True inconsistency in Python
    ... > comparisons in the sense that we don't always compare to a boolean ... An explicit comparison for an individual value _when there are ... It's not at all consistent, ... If it is not redundant, ...
    (comp.lang.python)
  • Re: Readability of Delphi
    ... Consistency and Clarity are both _independently_ related to Uniformity. ... I can assure you consistent indenting is clearer :-) ... Consistently random is still consistent. ... Again, this seems to be equating clarity with lack of ambiguity, which ...
    (borland.public.delphi.non-technical)