[fpc-devel] Semicolon before else
graemeg.lists at gmail.com
Tue Jan 26 07:42:24 CET 2010
David W Noon wrote:
>> case p of
>> '1': do_1;
>> '2' if (q > 0) then do_2;
>> else do_3;
>> It is not clear if else should be part of branch '2' (part of if
>> statement), or else branch for case.
> A quick examination of Jensen & Wirth's original Pascal grammar will
> tell you how that should be parsed: in Pascal there is *never* a
> semi-colon between the "then" clause and the "else" in an "if"
I must agree with David. The idea of the extra semi-colon just adds
confusion and no extra value.
Example where 'do_3 is part of the case statement:
case p of
'2' if (q > 0) then do_2;
Example where 'do_3' is part of the '2' if/else statement:
case p of
'2' if (q > 0) then do_2
Syntax and understanding is as clear as rain. Adding extra semi-colon, as
you suggested, is not.
As for the 'otherwise' syntax. You are correct, I have never heard or seen
it before. :-) But it is documented in the FPC Language Reference section
- Graeme -
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
More information about the fpc-devel