[fpc-devel] Semicolon before else

Marc Weustink marc.weustink at cuperus.nl
Fri Jan 29 12:11:07 CET 2010


Aleksa Todorovic wrote:
> On Fri, Jan 29, 2010 at 11:42, Michael Van Canneyt
> <michael at freepascal.org>  wrote:
>>
>> It breaks the behavious of case:
>>
>> case b of
>>   1 : something;
>>   2 : If a then
>>        DoSomethingElse;
>> else
>>   DoElse
>> end;
>>
>> As it is now, b=2 and a=False will result in no code executed.
>>
>> After the patch, B=2 and a=False will result in DoElse.
>>
>
> Have you actually tried it? I've tested those cases and they should work.


Then in your patch, how do you distinguish between the else belonging to 
the case statement and the else belonging to the if ?

Since if I followed this thread correctly, the following is allowed:

   if a then DoSomething; else DoSomethingElse;

So we have an "old style" case statement:

case foo of
   1: DoOne;
   2: if a then DoA;
else
   DoElse;
end;

in this case it is clear, the else belongs to the case.

Now with your patch

case foo of
   1: DoOne;
   2: if a then DoA;
else
   DoElse;
end;

should it be read as
   2: if a then DoA; else DoElse;

or
   case
    ....
   else
     DoElse;


???

Marc



More information about the fpc-devel mailing list