[fpc-devel] Semicolon before else

Arnstein Prytz arnstein.prytz at jcu.edu.au
Tue Jan 26 10:40:33 CET 2010


On 2010-01-26 16:51, Graeme Geldenhuys wrote:
> 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 -
> 
I believe `otherwise' was in VAX/VMS Pascal in the early 80's, which, I
must say, was a Pascal implementation way ahead of its time, including
the passing of dynamic arrays, and much more.

Regards, Arnstein.
-- 
----------------------------------------------------------------------------
Arnstein Prytz				           Arnstein.Prytz at jcu.edu.au
Australian Coastal Ocean Radar Network		          ph:  61-7-47815565
Marine Geophysical Laboratory
James Cook University
Townsville, Queensland 4811, Australia
----------------------------------------------------------------------------



More information about the fpc-devel mailing list