Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
is THEN necessary?
#2
THEN is used both for compatibility's sake with Sinclair and FreeBASIC and as "region" separator in the parsing phase.
The common structure is:
Code:
IF <condition> THEN <sentence> END IF
Here "<condition>" is something very fussy. It could be just "1", or something more complex like 3+A* Cos(pi) / 180.0.
Look at this example:
Code:
IF a a = a + 1: END IF
Makes the code less readable and could introduce some ambiguity in the parser. The THEN token marks the finish of the <expression> region. C does not uses the "THEN", but requires mondatory parenthesis around <expression> to treat this ambiguity.
Anyway, I've tested it and the THEN can be made optional... but again this goes away from BASIC. :| where legibility matters

What about the rest of users? What do you think?

Update: The best way to tackle this problem is to use a good IDE which will warns you of the missing THEN (this is a complex task) or even generate the IF THEN template for you.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)