Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Jonas Maebe
On 29 Jan 2010, at 21:17, Marco van de Voort wrote: > I don't know if a GCC frontend can directly parse headers in multiple > languaes. It would mean multiple frontends in one binary and afaik the gcc > frontends are separate binaries? All the C frontends are in one binary. I was not talking abo

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Marco van de Voort
In our previous episode, Jonas Maebe said: > > I'd like to hear your opinion on what exactly causes this too. I > > thought > > about it, and would roughly say: > > > > 1) the FPC cg accepts roughly a kind of superset of pascal dialects, > > and the dialect modes map > > onto it. > > 2) the fac

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Aleksa Todorovic
On Fri, Jan 29, 2010 at 16:22, Jonas Maebe wrote: > > On 29 Jan 2010, at 16:12, Aleksa Todorovic wrote: > >>> >>> Depends. I do see a minor point for e.g. ++ and --, since I have been >>> bitten >>> by that when translating e.g. compression code (paszlib, lz77) when these >>> are used in complex n

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Nikolai Zhubr
29.01.2010 14:47, Juha Manninen: [trim] There are some cases already where you can use a semicolon or leave it out. Not exactly, IMHO. The original point (AFAIK) was that semicolon is a separator. That is, it is to be used _between_ operators, not _inside_ of. And in accordance, originally pa

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Jonas Maebe
On 29 Jan 2010, at 16:12, Aleksa Todorovic wrote: Depends. I do see a minor point for e.g. ++ and --, since I have been bitten by that when translating e.g. compression code (paszlib, lz77) when these are used in complex nested loops. Hopefully, it would be easy to implement it "manuall

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Aleksa Todorovic
On Fri, Jan 29, 2010 at 13:23, Marco van de Voort wrote: > > Depends. I do see a minor point for e.g. ++ and --, since I have been bitten > by that when translating e.g. compression code (paszlib, lz77) when these > are used in complex nested loops. Hopefully, it would be easy to implement it "ma

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Jonas Maebe
On 29 Jan 2010, at 15:08, Marco van de Voort wrote: I'd like to hear your opinion on what exactly causes this too. I thought about it, and would roughly say: 1) the FPC cg accepts roughly a kind of superset of pascal dialects, and the dialect modes map onto it. 2) the fact that precompile

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Daniël Mantione
Op Fri, 29 Jan 2010, schreef Jonas Maebe: GCC supports several different C standards (K&R, C89, C99, ...), G++ supports different C++ standards, ... And as far as I know, you can also combine compiled source files written in different language variants in the same final binary. Here you do

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Marco van de Voort
In our previous episode, Jonas Maebe said: > >> program. You just have to translate the headers > > > > Right. That is the limitation. (well more a difference) > As I said, the same limitation goes for FPC: if you want to use a > library written in Objective-C from Objective-Pascal, you also h

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Jonas Maebe
On 29 Jan 2010, at 14:40, Juha Manninen wrote: There is no Modula2 mode. There is an Objective-Pascal mode, but no Objective-C mode. Sorry, yes. I knew it was Objective-Pascal, used in Mac, but I wrote it wrong. I remember reading about Modula2 mode but it must have been just an idea. I

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Marco van de Voort
In our previous episode, Juha Manninen said: > > There is no Modula2 mode. There is an Objective-Pascal mode, but no > > Objective-C mode. > > Sorry, yes. I knew it was Objective-Pascal, used in Mac, but I wrote it wrong. > I remember reading about Modula2 mode but it must have been just an idea

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Juha Manninen
> There is no Modula2 mode. There is an Objective-Pascal mode, but no > Objective-C mode. Sorry, yes. I knew it was Objective-Pascal, used in Mac, but I wrote it wrong. I remember reading about Modula2 mode but it must have been just an idea. > Units compiled in different dialects can indeed b

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Jonas Maebe
On 29 Jan 2010, at 14:10, Juha Manninen wrote: Now when I think of it, the new FPC language modes can solve many such problems. I understood there are Modula2 and Objective-C modes. There is no Modula2 mode. There is an Objective-Pascal mode, but no Objective-C mode. And they can use the

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Doug Chamberlin
On 1/29/2010 4:22 AM, Juha Manninen wrote: Anyway, this is a rather small thing. Most challenges in programming are somewhere else than in the use of a semicolon. This is so, so wrong. It is not a small thing at all. You have redefined the language is a subtle but significant way. I fear if

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Juha Manninen
> Excellent example and perfectly showing where the new behaviour would break > existing code without notice. I vote against this feature too, purely > because it is inconsistent in behaviour. The original inconsistency is that ELSE is reused in CASE statement. If it used OTHERWISE or something a

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Graeme Geldenhuys
Marc Weustink wrote: > > So this feature is inconsistent ? +1 > 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, wit

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Mark Morgan Lloyd
Matt Emson wrote: It is just a risk without real benefit attached to it, so I'm against. +1 To Be brutally honest - +1 for me too. This is very much a solution in search of a problem. If I were looking for any C/C++/C# style features to be added to the language, I would look at the f

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Marc Weustink
Matt Emson wrote: Stefan Kisdaroczi wrote: Am 29.01.2010 12:08, schrieb Marco van de Voort: I don't really see a need for this. Some languages are terminator, some are separator. We are also not Basic in that we try to disambiguate every possible syntax. It is just a risk without real benefit

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Marc Weustink
Aleksa Todorovic wrote: On Fri, Jan 29, 2010 at 12:11, Marc Weustink wrote: Aleksa Todorovic wrote: On Fri, Jan 29, 2010 at 11:42, Michael Van Canneyt wrote: It breaks the behavious of case: case b of 1 : something; 2 : If a then DoSomethingElse; else DoElse end; As it is

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Marco van de Voort
In our previous episode, dmitry boyarintsev said: > > possible syntax. > > > > It is just a risk without real benefit attached to it, so I'm against. > > +1 > why should pascal care about C legacy? Depends. I do see a minor point for e.g. ++ and --, since I have been bitten by that when translati

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread dmitry boyarintsev
On Fri, Jan 29, 2010 at 2:08 PM, Marco van de Voort wrote: > I don't really see a need for this. Some languages are terminator, some are > separator. We are also not Basic in that we try to disambiguate every > possible syntax. > > It is just a risk without real benefit attached to it, so I'm agai

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Aleksa Todorovic
On Fri, Jan 29, 2010 at 12:11, Marc Weustink wrote: > Aleksa Todorovic wrote: >> >> On Fri, Jan 29, 2010 at 11:42, Michael Van Canneyt >>  wrote: >>> >>> It breaks the behavious of case: >>> >>> case b of >>>  1 : something; >>>  2 : If a then >>>       DoSomethingElse; >>> else >>>  DoElse >>> e

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Juha Manninen
Hi. Your explanation is correct but my approach is more pragmatic and less philosophical. There are some cases already where you can use a semicolon or leave it out. Like : begin if a > 100 then DoThing1 else if a > 50 then DoThing2 else if a > 10 then DoThing3 else DoThi

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Marc Weustink
Aleksa Todorovic wrote: On Fri, Jan 29, 2010 at 11:42, Michael Van Canneyt 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

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Matt Emson
Stefan Kisdaroczi wrote: Am 29.01.2010 12:08, schrieb Marco van de Voort: I don't really see a need for this. Some languages are terminator, some are separator. We are also not Basic in that we try to disambiguate every possible syntax. It is just a risk without real benefit attached to it,

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Stefan Kisdaroczi
Am 29.01.2010 12:08, schrieb Marco van de Voort: > In our previous episode, Aleksa Todorovic said: >> >> Absolutely! But in the first instance, we need to choose if this is >> actually going to be part of FPC or not. > > I don't really see a need for this. Some languages are terminator, some are >

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Marco van de Voort
In our previous episode, Aleksa Todorovic said: > > Absolutely! But in the first instance, we need to choose if this is > actually going to be part of FPC or not. I don't really see a need for this. Some languages are terminator, some are separator. We are also not Basic in that we try to disambi

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Thaddy
As well as both if a then DoSomething else DoOtherThing; and if a then DoSomething; else DoOtherThing; At least to me they are :-) This "feature" is so unclean and so poorly informed about WHY the ; is a part of the language. First of all, Pascal is not a line based language.

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Aleksa Todorovic
On Fri, Jan 29, 2010 at 11:42, Michael Van Canneyt 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 w

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Aleksa Todorovic
On Fri, Jan 29, 2010 at 11:36, Juha Manninen wrote: > > It means there is no ambiguity and the patch can be applied without breaking > any code. > Or, is there some detail I have missed? I have not found any problems, but since this is serious syntax change, I cannot guarantee it. ___

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Michael Van Canneyt
On Fri, 29 Jan 2010, Juha Manninen wrote: Because FPC does not support semicolon before else :-) Ok, I remembered it connects to the first IF when there is semicolon. Apparently I remembered wrong... It means there is no ambiguity and the patch can be applied without breaking any code. Or,

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Juha Manninen
> Because FPC does not support semicolon before else :-) Ok, I remembered it connects to the first IF when there is semicolon. Apparently I remembered wrong... It means there is no ambiguity and the patch can be applied without breaking any code. Or, is there some detail I have missed? Juha M

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Aleksa Todorovic
On Fri, Jan 29, 2010 at 10:22, Juha Manninen wrote: > > BTW, why doesn't the example code compile in current FPC? > I remember such code compiled in Delphi but I am not sure and I don't have > Delphi now to check. Because FPC does not support semicolon before else :-)

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Mark Morgan Lloyd
Pete Cervasio wrote: On Friday 29 January 2010 01:52:59 Juha Manninen wrote: For Graeme and others: the problem is not the amount of typing. The problem is that you can easily forget this semicolon It's not like you have to drop off your punch cards and come back tomorrow afternoon, is it?

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Aleksa Todorovic
On Fri, Jan 29, 2010 at 08:09, Graeme Geldenhuys wrote: > > 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; As we

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Juha Manninen
>What are you doing? Get to work. >Compiling. >Oh, ok. Right, It was a forced social break with C compilers on old computers. When you were really in a creative mood then it ate lots of your time and energy. When the compiler finished your idea was maybe gone and you had

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Aleksa Todorovic
On Fri, Jan 29, 2010 at 08:56, Thaddy wrote: > Aleksa Todorovic wrote: >> >> else is handled as part of "if b then" -> the closest preceeding if: > > This would break almost all my code. Hm... it shouldn't. As far as I tested it, it correctly handles all possible situations. If it doesn't take yo

Re: [fpc-devel] Semicolon before else

2010-01-29 Thread Pete Cervasio
On Friday 29 January 2010 01:52:59 Juha Manninen wrote: > For Graeme and others: the problem is not the amount of typing. The problem > is that you can easily forget this semicolon It's not like you have to drop off your punch cards and come back tomorrow afternoon, is it? I usually don't even

Re: [fpc-devel] Semicolon before else

2010-01-28 Thread Thaddy
Aleksa Todorovic wrote: else is handled as part of "if b then" -> the closest preceeding if: This would break almost all my code. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel

Re: [fpc-devel] Semicolon before else

2010-01-28 Thread Juha Manninen
> if x < 2 then > if x > 0 then > Writeln('x=1'); > else > Writeln('x=0'); I was going to write that's not backward compatible, but it doesn't actually compile with current FPC. I remembered now ELSE would be tied to the first IF. Anyway, there are some weird cases when it'

Re: [fpc-devel] Semicolon before else

2010-01-28 Thread Graeme Geldenhuys
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 si

Re: [fpc-devel] Semicolon before else

2010-01-28 Thread Aleksa Todorovic
On Fri, Jan 29, 2010 at 00:00, Juha Manninen wrote: > > How does your patch handle this? : > >  if a then >    if b then >     DoSomething; >   else >     DoOtherThing; > else is handled as part of "if b then" -> the closest preceeding if: program test3; var x: Integer; begin x := 1; if x

Re: [fpc-devel] Semicolon before else

2010-01-28 Thread Thaddy
How does your patch handle this? : if a then if b then DoSomething; else DoOtherThing; Syntax error ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel

Re: [fpc-devel] Semicolon before else

2010-01-28 Thread Juha Manninen
> - full backward compatibility: problematic else inside case is > correctly recognized (weather it is part of last if statement or part > of case, including nested if/else-s) Impressive! I would be happy with that syntax change. However I understood all FPC authors were not as happy with such ch

Re: [fpc-devel] Semicolon before else

2010-01-28 Thread Aleksa Todorovic
On Tue, Jan 26, 2010 at 10:56, Juha Manninen wrote: > > Object Pascal is otherwise a nice language but there are few annoying syntax > details that other languages have solved better. Three such cases pop into my > mind: > > 1. This semicolon / no semicolon irritation. I'm trying to solve that on

Re: [fpc-devel] Semicolon before else

2010-01-27 Thread Aleksa Todorovic
On Tue, Jan 26, 2010 at 07:42, Graeme Geldenhuys wrote: > > 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. On more probably less known reserved identifier is FAIL. You can use it only

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Mark Morgan Lloyd
Marco van de Voort wrote: In our previous episode, Aleksa Todorovic said: But in that case what's needed is not a simple change to this one case but an option to accept Modula-2 style syntax where you've got if...then...end; etc. hence eliminating the "dangling else" problem. Agree fully, that'

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Joost van der Sluis
On Tue, 2010-01-26 at 09:23 +0200, Graeme Geldenhuys wrote: > Daniël Mantione wrote: > > > > Indeed, it would be undesired to accept that semicolon. What makes me > > uncomfortable is that he went to the trouble of modifying the compiler for > > it. We should encourage that. > > > I know, it i

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Graeme Geldenhuys
Graeme Geldenhuys wrote: > > Example where 'do_3 is part of the case statement: [...snip...] > Example where 'do_3' is part of the '2' if/else statement: [...snip...] Oops, in both examples I forgot the semi-colon after the '2' in the case statement. Copy and Paste is evil. :) Regards, - Gr

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Aleksa Todorovic
On Tue, Jan 26, 2010 at 11:27, Michael Schnell wrote: > On 01/26/2010 07:51 AM, Daniël Mantione wrote: >>   We should encourage that. > > Maybe from his work he could derive an "acceptable" patch that issues an > "ambiguity" warning just if a Semicolon decides between two > syntactically correct c

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Aleksa Todorovic
On Tue, Jan 26, 2010 at 07:42, Graeme Geldenhuys wrote: > David W Noon wrote: > > 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 >    

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Juha Manninen
> Never use "then .. else" naked but instead "then begin ... end else > begin ... end" with appropriate indentation (I prefer "end else begin" > alone in a single line, but this is a matter of taste :) ; I also do that sometimes just to avoid the semicolon problem, even if there is only one comma

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Michael Schnell
On 01/26/2010 07:51 AM, Daniël Mantione wrote: > We should encourage that. Maybe from his work he could derive an "acceptable" patch that issues an "ambiguity" warning just if a Semicolon decides between two syntactically correct code variants with different behavior. -Michael _

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Michael Schnell
On 01/26/2010 07:51 AM, Daniël Mantione wrote: > "Otherwise" is used in some Pascal dialects instead of "else". This is > where it comes from. Delphi does not seem to accept it... -Michael ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Michael Schnell
Never use "then .. else" naked but instead "then begin ... end else begin ... end" with appropriate indentation (I prefer "end else begin" alone in a single line, but this is a matter of taste :) ; -Michael ___ fpc-devel maillist - fpc-devel@lists.fr

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Juha Manninen
Hi, I actually suggested a similar change for Delphi years ago. Its value and benefit is obvious: when adding ELSE to and existing IF statement. if a then DoSomething; must have a semicolon, but if a then DoSomething else DoSomethingElse; must NOT have a semicolon. It is irr

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Marco van de Voort
In our previous episode, Aleksa Todorovic said: > >> But in that case what's needed is not a simple change to this one case > >> but an option to accept Modula-2 style syntax where you've got > >> if...then...end; etc. hence eliminating the "dangling else" problem. > > > > Agree fully, that's how W

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Arnstein Prytz
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 fo

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Aleksa Todorovic
On Tue, Jan 26, 2010 at 10:11, Marco van de Voort wrote: > In our previous episode, Mark Morgan Lloyd said: >> >> > Agree. My primary intention was not to change official language, but >> > to try to make a change which will help me in my work. I just shared >> > it with others. >> >> But in that

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Marco van de Voort
In our previous episode, Mark Morgan Lloyd said: > > > Agree. My primary intention was not to change official language, but > > to try to make a change which will help me in my work. I just shared > > it with others. > > But in that case what's needed is not a simple change to this one case > bu

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Mark Morgan Lloyd
Aleksa Todorovic wrote: Agree. My primary intention was not to change official language, but to try to make a change which will help me in my work. I just shared it with others. But in that case what's needed is not a simple change to this one case but an option to accept Modula-2 style synta

Re: [fpc-devel] Semicolon before else

2010-01-26 Thread Aleksa Todorovic
Thank you for your responses. On Tue, Jan 26, 2010 at 08:23, Graeme Geldenhuys wrote: > Daniël Mantione wrote: >> >> Indeed, it would be undesired to accept that semicolon. What makes me >> uncomfortable is that he went to the trouble of modifying the compiler for >> it. We should encourage that.

Re: [fpc-devel] Semicolon before else

2010-01-25 Thread Graeme Geldenhuys
Daniël Mantione wrote: > > Indeed, it would be undesired to accept that semicolon. What makes me > uncomfortable is that he went to the trouble of modifying the compiler for > it. We should encourage that. I know, it is impressive that somebody went through all that trouble in modifying the co

Re: [fpc-devel] Semicolon before else

2010-01-25 Thread Daniël Mantione
Op Tue, 26 Jan 2010, schreef Graeme Geldenhuys: David W Noon wrote: Syntax and understanding is as clear as rain. Adding extra semi-colon, as you suggested, is not. Indeed, it would be undesired to accept that semicolon. What makes me uncomfortable is that he went to the trouble of modifyi

Re: [fpc-devel] Semicolon before else

2010-01-25 Thread Graeme Geldenhuys
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 > te

Re: [fpc-devel] Semicolon before else

2010-01-25 Thread David W Noon
On Tue, 26 Jan 2010 01:08:45 +0100, Aleksa Todorovic wrote about [fpc-devel] Semicolon before else: [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

[fpc-devel] Semicolon before else

2010-01-25 Thread Aleksa Todorovic
Hi, all! I used to work in Pascal (Delphi/fpc) for 10 years, and later had to go to C++ (because of my day job). Now, I'm back to fpc, and one thing I really miss is ability to have semicolon before else. So, here's (attached) patch for fpc that makes it possible. The only problematic place for t