; after then lazarus / 21-General ---------------------------------------------------------------------- BubikolRamios · 2026-02-11 11:41 No errors, runs as all ok, sure does not do what one wants. I guess sometimes it would be great if some kind of error/warning would be raised or something. Years ago had that situation at line going off screen, you can imagine (-: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if circleArray[i].growStop = false then;  circleArray[i].circle.r := circleArray[i].circle.r + 1; ---------------------------------------------------------------------- Martin_fr · 2026-02-11 11:59 While it wont really help if fully off screen, there is "user defined markup". I use that to highlight common mistakes like that. (Note, I also have "then ;" with a space, and in some cases even with 2 spaces) ---------------------------------------------------------------------- eny · 2026-02-11 16:58 Quote from: Martin_fr on February 11, 2026, 12:59:18 pmI use that to highlight common mistakes like that.You mean comparing a boolean variable with 'true' or 'false'?  I wouldn't call a semicolon after 'then' a common mistake. It's one of the things that sets Pascal aside from the C-like languages: it's a separator, not a terminator. Maybe if one comes from a C-like environment switching to (Free) Pascal. ---------------------------------------------------------------------- 440bx · 2026-02-11 18:02 Quote from: eny on February 11, 2026, 05:58:44 pmYou mean comparing a boolean variable with 'true' or 'false'?  Indeed, that is the mistake in that code. ---------------------------------------------------------------------- Martin_fr · 2026-02-11 18:53 Quote from: eny on February 11, 2026, 05:58:44 pmI wouldn't call a semicolon after 'then' a common mistake. Well, you don't need to call it that.... But step by step. Its not an error, its a correct pascal construct. But then, so is any code that compiles. Even if it does not do what you meant it to do. And yes, you can intentionally write "then ;" if you intentionally want the empty statement. I have actually done that myself. Yet, then again, codetools has more than once added a semicolon while I was writing a condition for an "if", and that ; hand remained in place after the "then". So it is a mistake that - at least for me, and likely the OT - happens regularly.  In any case, its a mistake that can happen, and if it does, it can be hard to spot. ---------------------------------------------------------------------- Martin_fr · 2026-02-11 19:00 Quote from: 440bx on February 11, 2026, 07:02:43 pmIndeed, that is the mistake in that code. Maybe earlier in that code (missing from the sample) there is something like Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const false = 'OFF';or Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type TFoo = (foo, bar, false, help); When you got old properties that RTTI stream from a stringified representation, and you need to change the type,  then you may need to have an enum that contains the old names... ---------------------------------------------------------------------- n7800 · 2026-02-11 19:41 It's hard to say how often users encounter this while coding, but I found a couple dozen instances in the release, including the Lazarus IDE and its packages (already fixed): * https://gitlab.com/freepascal.org/lazarus/lazarus/-/merge_requests/403 * https://gitlab.com/freepascal.org/lazarus/ccr/-/issues/39109 Quote from: Martin_fr on February 11, 2026, 07:53:49 pmYet, then again, codetools has more than once added a semicolon while I was writing a condition for an "if", and that ; hand remained in place after the "then". So it is a mistake that - at least for me, and likely the OT - happens regularly.  Perhaps that the IDE could indeed contribute to this error, there's been an open issue regarding this for a long time: * https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/37818 ---------------------------------------------------------------------- 440bx · 2026-02-11 20:13 Quote from: Martin_fr on February 11, 2026, 08:00:29 pmQuote from: 440bx on February 11, 2026, 07:02:43 pmIndeed, that is the mistake in that code. Maybe earlier in that code (missing from the sample) there is something like Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const false = 'OFF';or Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type TFoo = (foo, bar, false, help); When you got old properties that RTTI stream from a stringified representation, and you need to change the type,  then you may need to have an enum that contains the old names... It's true that things like that can be done and they are valid Pascal but, I consider the creation of such code to represent mistakes (even though they compile) caused by rather poor programming. I will, however, concede that as far as the compiler is concerned those aren't mistakes (at least not syntactical ones) since they compile.  Semantically, I don't consider them mistakes, I consider them atrocities. IMO, the language should NOT allow the redefinition of quite a number of standard identifiers which it currently allows to be redefined.  Such redefinitions rarely, if ever, contribute to creating better code, on the contrary, more often than not they contribute to mislead the programmers who are left with the unenviable task of maintaining such code. IMO, some "characteristics" of the language should be immutable, among many, the identifier "FALSE" should always be a boolean type with the value zero (at least in most common architectures.)  If the programmer wants something different then declare a new identifier instead of misleading programmers by making "creative" redefinitions of standard identifiers. ---------------------------------------------------------------------- creaothceann · 2026-02-11 20:27 "then ;" is usually an error, but it can happen when you use macros that do or do not include some code based on compile-time conditions. Also, a recent example where I (kinda) had to write an empty statement: I was writing an advanced record that had private variables but public properties. One of the variables was only added for alignment, i.e. padding, it wasn't used in the code. Naturally the compiler noticed that and added a note to the messages window: Quote.pas(31,3) Note: Private field "._padding" is never used Since I try to keep the number of messages as low as possible, the solution was adding the line "if (_padding = 0) then ;" somewhere. ---------------------------------------------------------------------- n7800 · 2026-02-11 20:51 Quote from: 440bx on February 11, 2026, 09:13:49 pmIMO, the language should NOT allow the redefinition of quite a number of standard identifiers which it currently allows to be redefined.  Such redefinitions rarely, if ever, contribute to creating better code, on the contrary, more often than not they contribute to mislead the programmers who are left with the unenviable task of maintaining such code. Off topic, but I assume that such capabilities appeared precisely for the purpose of supporting... legacy code. After all, nothing prevents from not using them and rewriting the entire code correctly. That's the programmer's decision. ---------------------------------------------------------------------- 440bx · 2026-02-11 21:29 Quote from: n7800 on February 11, 2026, 09:51:10 pmOff topic, but I assume that such capabilities appeared precisely for the purpose of supporting... legacy code. I honestly don't think that's the reason but, I cannot prove it.  Fortunately, it is somewhat rare to see standard identifiers redefined in code (likely because doing that really is a programming atrocity.) Quote from: n7800 on February 11, 2026, 09:51:10 pmAfter all, nothing prevents from not using them and rewriting the entire code correctly. That's the programmer's decision. I am definitely a strong supporter of letting the programmer decide most things but, the things that are defined by the language should be immutable, e.g, what FALSE means and its value and, that's just one in a large number of identifiers the compiler allows to be redefined. IMO, the compiler should NOT give a choice and, if there is legacy code that breaks because of that, then it's time to fix that code instead of forever supporting poor programming for the sake of "backwards compatibility". IOW, the compiler should be _predictable_ and that _requires_ ensuring its basic types and definitions are immutable, otherwise predictability goes out the window thereby causing all kinds of headaches. It's a bit like strong type checking.  Forcing the programmer to live by the rules prevents mistakes. ---------------------------------------------------------------------- PascalDragon · 2026-02-12 20:41 Quote from: 440bx on February 11, 2026, 10:29:20 pmIOW, the compiler should be _predictable_ and that _requires_ ensuring its basic types and definitions are immutable, otherwise predictability goes out the window thereby causing all kinds of headaches. The point is that such identifiers are considered part of the namespace of the System unit. And due to ordinary language rules it's possible to redeclare symbols declared in another unit, cause they're still accessible using System.*. It also applies to intrinsics like Length, High, etc. or funnily enough Break and Continue (cause they're not keywords in the language sense). ---------------------------------------------------------------------- 440bx · 2026-02-12 20:52 Quote from: PascalDragon on February 12, 2026, 09:41:09 pmIt also applies to intrinsics like Length, High, etc. or funnily enough Break and Continue (cause they're not keywords in the language sense). That is the root of the problem.  Many Pascal identifiers should be keywords thus preventing a programmer from getting too "creative". ---------------------------------------------------------------------- Curt Carpenter · 2026-02-12 22:36 Wonder how many man-hours have been spent trying to find this problem when the ; is off screen?  It's a classic! ---------------------------------------------------------------------- Hansvb · 2026-02-13 15:25 Quotethere is "user defined markup".Never used it until now. This is a great option. Another option I shouldn't forget to set up after a new install. ---------------------------------------------------------------------- cdbc · 2026-02-13 19:13 Hi After I got used to it, it's the first thing I setup on a new install  ...I miss it instantly, when it's not there  Regards Benny ---------------------------------------------------------------------- Curt Carpenter · 2026-02-13 21:06 Is there a wiki on "(IDE) things to setup after a new install"? ---------------------------------------------------------------------- Martin_fr · 2026-02-13 23:38 Quote from: Curt Carpenter on February 13, 2026, 10:06:01 pmIs there a wiki on "(IDE) things to setup after a new install"? Not that I am aware off. And there are too many things... And it doesn't just end at enabling stuff, all the neat little bit where codetools can do stuff for you (see my signature for the link), there probably are some you don't know yet. And lots of other commands the IDE has. - See the links in my sig - browse through the IDE options   - browse all the commands you can assign in the keymap   - check the mouse settings - browse the list of packages => With that info, be welcome to start such a wiki page. Here is another bit that you may found useful. Have you ever single stepped in the debugger, and at some point you look at a watch and you realize: that has the wrong value. Then you ask yourself, did it have that value one step back? or 2 steps back? If you did the stepping, and the value was evaluated (shown in watches), but you didn't pay it attention => the history window gives you access to the last 20 (or something) times you stepped (but only values that had been evaluated, it does not backward compute). Hunting a mem leak? Copy it from console, and paste into "view > leaks and traces", and you can click the lines in the trace and the IDE jumps to the locations. You can install a file browser. IDE scout => search for features ... ---------------------------------------------------------------------- Curt Carpenter · 2026-02-14 15:09 Thank you very much for the links:  I'll spend some time over the next few days exploring them and taking some notes.  I don't doubt that I'm only using a small fraction of all the tools the IDE provides -- despite quite a few years of use!. ---------------------------------------------------------------------- dseligo · 2026-02-15 21:27 Quote from: Curt Carpenter on February 12, 2026, 11:36:16 pmWonder how many man-hours have been spent trying to find this problem when the ; is off screen?  It's a classic!  Maybe it would be a nice new feature for FPC to emit warning when there is only empty statement. In cases like this, e.g.: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i If a = b then ; repeatuntil a = b; while a = b do ; procedure x;beginend; case a of1:;end; ---------------------------------------------------------------------- Martin_fr · 2026-02-15 21:38 Quote from: dseligo on February 15, 2026, 10:27:29 pmMaybe it would be a nice new feature for FPC to emit warning when there is only empty statement. Any of those empty loop can be a perfectly valid spin lock. Any of the vars can be altered by another thread (and dirty read may be fine). Empty procedure may be needed to take the address of, if you have code that insists on a code ref, and you don't want it to do anything. Empty "if" could also happen, if the evaluation of the condition has side effects. (and maybe the partial bool eval is used for some trickery) ---------------------------------------------------------------------- 440bx · 2026-02-15 22:15 another reason to have a "then ;" is when it is followed by an "else".  This saves from having to "not" the condition which if complex could extend over several lines and made harder to read by the presence of the "not". ---------------------------------------------------------------------- Martin_fr · 2026-02-15 22:44 Quote from: 440bx on February 15, 2026, 11:15:01 pmanother reason to have a "then ;" is when it is followed by an "else".  This saves from having to "not" the condition which if complex could extend over several lines and made harder to read by the presence of the "not". Not exactly, there is no ";" allowed before the else. But you would have the empty statement after the "then" ---------------------------------------------------------------------- 440bx · 2026-02-15 22:49 Quote from: Martin_fr on February 15, 2026, 11:44:54 pmNot exactly, there is no ";" allowed before the else. But you would have the empty statement after the "then" You're absolutely right.  I momentarily forgot that in Pascal the ; is a statement separator not a terminator. ---------------------------------------------------------------------- dseligo · 2026-02-15 22:55 Quote from: Martin_fr on February 15, 2026, 10:38:40 pmQuote from: dseligo on February 15, 2026, 10:27:29 pmMaybe it would be a nice new feature for FPC to emit warning when there is only empty statement. Any of those empty loop can be a perfectly valid spin lock. Any of the vars can be altered by another thread (and dirty read may be fine). Empty procedure may be needed to take the address of, if you have code that insists on a code ref, and you don't want it to do anything. Empty "if" could also happen, if the evaluation of the condition has side effects. (and maybe the partial bool eval is used for some trickery) FPC emits warnings for other stuff that are valid also. I think this empty statements are programming errors in more cases than i.e. if you don't use parameter of method like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);begin  WriteLn('OnClose');end; And code above is also valid, and annoys more frequently than it would annoy warning for empty statement (when they are valid). ---------------------------------------------------------------------- Martin_fr · 2026-02-15 23:30 Quote from: dseligo on February 15, 2026, 11:55:24 pmFPC emits warnings for other stuff that are valid also. True... But also: Empty statement. Not: Some selected empty statement. A lot of code will give warnings. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if foo = bar then begin  DoAbc;  DoXyz;end; Do you see the empty statement in the above code? It's after "DoXyz;" => the semicolon is not a statement terminator, but a separator. After the last statement, no separator is needed. But lots of code has them. And that are all empty statements. ---------------------------------------------------------------------- dseligo · 2026-02-15 23:40 Quote from: Martin_fr on February 16, 2026, 12:30:06 amQuote from: dseligo on February 15, 2026, 11:55:24 pmFPC emits warnings for other stuff that are valid also. True... But also: Empty statement. Not: Some selected empty statement. A lot of code will give warnings. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if foo = bar then begin  DoAbc;  DoXyz;end; Do you see the empty statement in the above code? It's after "DoXyz;" => the semicolon is not a statement terminator, but a separator. After the last statement, no separator is needed. But lots of code has them. And that are all empty statements. You are correct - and in this case I add ; on purpose (and out of a habit) - because if I need to write some more lines below, I don't need to add ; in previous line. Also, FPC has much bigger priorities now than this. ---------------------------------------------------------------------- valdir.marcos · 2026-02-16 06:49 Quote from: PascalDragon on February 12, 2026, 09:41:09 pmQuote from: 440bx on February 11, 2026, 10:29:20 pmIOW, the compiler should be _predictable_ and that _requires_ ensuring its basic types and definitions are immutable, otherwise predictability goes out the window thereby causing all kinds of headaches. The point is that such identifiers are considered part of the namespace of the System unit. And due to ordinary language rules it's possible to redeclare symbols declared in another unit, cause they're still accessible using System.*. It also applies to intrinsics like Length, High, etc. or funnily enough Break and Continue (cause they're not keywords in the language sense).Very interesting.