Graeme Geldenhuys
Mon, 25 Jan 2010 22:42:04 -0800
David W Noon wrote: > > [snip] >> case p of >> '1': do_1; >> '2' if (q > 0) then do_2; >> else do_3; >> end; >> >> 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" > statement.
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
'1': do_1;
'2' if (q > 0) then do_2;
else do_3;
end;
Example where 'do_3' is part of the '2' if/else statement:
case p of
'1': do_1;
'2' if (q > 0) then do_2
else do_3;
end;
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
10.2.2.
Regards,
- Graeme -
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel