[fpc-devel] Semicolon before else
Graeme Geldenhuys
graemeg.lists at gmail.com
Fri Jan 29 08:09:44 CET 2010
Aleksa Todorovic wrote:
>> if a then
>> if b then
>> DoSomething;
>> else
>> DoOtherThing;
>>
>
> else is handled as part of "if b then" -> the closest preceeding if:
That is so confusing... if the major issue is that if you wanted to add
more lines before of after the else, then simply wrap the code with
begin..end blocks. If you think that it is too much typing, use a typing
tutor to improve you typing skills or use a decent editor that can
automatically add those begin/end blocks for you (normally called "code
templates").
Non-confusing end result looks like this:
if a then
begin
DoSomething;
end
else
begin
DoOtherThing;
end;
or
if a then
begin
DoSomething;
end
else begin
DoOtherThing;
end;
Lets take Lazarus IDE as an example of a good editor:
USAGE:
* type the first few letters and then press Ctrl+J
ifb - if statement
b - begin end
be - begin end else begin end
bg - begin end
ifb - if statement with begin end
ifeb - if then else with begin end blocks
ife - if then (no begin/end) else (no begin/end)
And these are just the begin/end and if statement templates. There are
many, many other templates too. So your "solution" just seems like to much
work modifying the compiler and the end result is code the developer cannot
understand or finds very confusing.
But then it's like you said: It's your patch, use it or don't. :)
Regards,
- Graeme -
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/
More information about the fpc-devel
mailing list