[futurebasic] ZB=FB=bad / FBIII=good?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 1997 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Sat, 29 Nov 1997 21:20:35 +1300
The FOR loop unhappiness
------------------------
ZBasic and FB made a poor choice in implementing FOR loops, such that the
loop body is _always_ executed at least once, regardless of the start, end
and increment values. To allow the body to be skipped we must bracket the
loop as shown:-

LONG IF last%>=first% ' else we want to skip the loop
   FOR j% = first% TO last%
    .. do stuff
   NEXT j%
END IF

FOR loops in BASIC are officially supposed to be implemented such that the
body can be executed zero times if appropriate. Some variants of BASIC got
unhappy loops in the days of tiny interpreters, which were too stupid to
follow the language definition. The only language with an officially
unhappy loop was FORTRAN. The late lamented MS QuickBasic did it right. How
about FBIII?

The LONG IF nonsense
--------------------
Ever felt embarrassed showing your source code to another programmer? The
LONG IF, inherited from ZBasic, curls my toes by its ineptness:-

LONG IF flagSet
  .. do stuff
XELSE
  .. do other stuff
END IF

Those other programmers snicker at the silly syntax and ask "Why LONG? Why
no THEN after LONG IF? Why XELSE? Why no ELSEIF?..."

In MS QuickBasic you could write, with no perceptible strain or discomfort:-
IF flagSet THEN
 .. do stuff
ELSEIF tr%=2 THEN
  .. do other
ELSE
 .. yet different
END IF

How about FBIII? Is it going to cast off the ugly and inflexible LONG IF?


Robert            robert.purves@...