[fpc-devel] Semicolon before else
    Marc Weustink 
    marc.weustink at cuperus.nl
       
    Fri Jan 29 13:27:55 CET 2010
    
    
  
Aleksa Todorovic wrote:
> On Fri, Jan 29, 2010 at 12:11, Marc Weustink<marc.weustink at cuperus.nl>  wrote:
>> 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 ?
>
> When compiler hits 'end' inside 'case', it analyzes syntax tree
> created for the last branch, and checks if there was semicolon before
> last else or not (which is clear sign if that else is part of if
> statement or case).
So this feature is inconsistent ?
Imagine I've a case like:
  case Foo of
    1 : DoOne;
    2 : If a then DoA; else DoNotA;
    3 : DoThree;
  end;
Now, due to changed requirements, 1 and 3 shout do the same, so I change 
the case into:
  case Foo of
    1,3 : DoOneAndThree;
    2 : If a then DoA; else DoNotA;
  end;
This will affect the meaning of 2 too, without noticing...
No thank you.
Marc
    
    
More information about the fpc-devel
mailing list