![]() |
|
is THEN necessary? - Printable Version +- Boriel Basic Forum (https://forum.boriel.com) +-- Forum: Compilers and Computer Languages (https://forum.boriel.com/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://forum.boriel.com/forumdisplay.php?fid=11) +---- Forum: Wishlist (https://forum.boriel.com/forumdisplay.php?fid=14) +---- Thread: is THEN necessary? (/showthread.php?tid=491) |
is THEN necessary? - slenkar - 2012-08-18 every time I do an IF statement I always forget THEN, can it be made optional? Re: is THEN necessary? - boriel - 2012-08-19 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 IFLook at this example: Code: IF a a = a + 1: END IFAnyway, 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. Re: is THEN necessary? - britlion - 2012-08-25 Could parse the ambiguity by saying "THEN" or newline? IF a (then) a=a+1 end if So an alternate if construction is: IF <condition> list of statements END IF Would that work? Re: is THEN necessary? - slenkar - 2012-08-25 yeah that would be good Re: is THEN necessary? - boriel - 2012-08-25 britlion Wrote:Could parse the ambiguity by saying "THEN" or newline?Not needed, surprisingly, I've managed to make the THEN optional quite easily. But this goes away from BASIC... Anyway, It will be uploaded soon. Re: is THEN necessary? - LCD - 2012-08-26 Oh, that is great! I always forget it too because it is not needed in PureBasic. The syntax is: IF a:a+1:ENDIF Re: is THEN necessary? - boriel - 2012-08-26 LCD Wrote:Oh, that is great!This is already uploaded in the RELEASE 1.2.9. Now let's go for 1.3.0 (sigh!). |