Re: [fpc-pascal] Legitimate use of for and break
On 2023-06-18 03:04, Hairy Pixels via fpc-pascal wrote: On Jun 18, 2023, at 1:07 AM, tsie...@softcon.com wrote: This is interesting, because it's the first time I've ever seen "break" as a valid command in pascal, and I've been using pascal since the mid/late 80s. All kinds of dialects too, and I've never seen break as a keyword. C, Python, Perl, sure, even shell scripts, but pascal? Never seen it used before. Is this a relatively new addition to fpc or something? I don't remember break NOT being in Pascal. How did you exit a loop otherwise, goto? Break is common in basically all languages now. Can't think of a language I've used without it. Obviously, loop is exited using the loop condition by default and that may be achieved without additional constructs, should it be break or goto. Yes, using break may be more elegant in certain cases, but that's another story. Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Legitimate use of for and break
> On Jun 18, 2023, at 1:07 AM, tsie...@softcon.com wrote: > > This is interesting, because it's the first time I've ever seen "break" as a > valid command in pascal, and I've been using pascal since the mid/late 80s. > All kinds of dialects too, and I've never seen break as a keyword. C, > Python, Perl, sure, even shell scripts, but pascal? Never seen it used > before. Is this a relatively new addition to fpc or something? I don't remember break NOT being in Pascal. How did you exit a loop otherwise, goto? Break is common in basically all languages now. Can't think of a language I've used without it. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Legitimate use of for and break
On 17/06/2023 19:07, Travis Siegel via fpc-pascal wrote: This is interesting, because it's the first time I've ever seen "break" as a valid command in pascal, and I've been using pascal since the mid/late 80s. All kinds of dialects too, and I've never seen break as a keyword. C, Python, Perl, sure, even shell scripts, but pascal? Never seen it used before. I've been using break very often in Pascal loops for 25 years since Delphi 2. Also continue. My code is littered with: repeat do_something; if x then BREAK; if y then CONTINUE; do_something_else; Application.ProcessMessages; if key_clicked then EXIT; until 0<>0; ProcessMessages allows the user to stop the loop if it is running out of control. Martin. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Legitimate use of for and break
On 17 June 2023 20:45:49 +0200, Jean SUZINEAU via fpc-pascal wrote: >Le 17/06/2023 à 20:07, Travis Siegel via fpc-pascal a écrit : >> Is this a relatively new addition to fpc or something? > >I 've just found it in my Delphi 7 code (and code very likely written for >Delphi 4), so I think it's there since at least 2000-2001 ... > >May be it appeared with Delphi 1 ? I believe it was added in TP/BP7. Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Legitimate use of for and break
Le 17/06/2023 à 20:07, Travis Siegel via fpc-pascal a écrit : Is this a relatively new addition to fpc or something? I 've just found it in my Delphi 7 code (and code very likely written for Delphi 4), so I think it's there since at least 2000-2001 ... May be it appeared with Delphi 1 ? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Legitimate use of for and break
This is interesting, because it's the first time I've ever seen "break" as a valid command in pascal, and I've been using pascal since the mid/late 80s. All kinds of dialects too, and I've never seen break as a keyword. C, Python, Perl, sure, even shell scripts, but pascal? Never seen it used before. Is this a relatively new addition to fpc or something? On 6/16/2023 1:51 PM, Hairy Pixels via fpc-pascal wrote: On Jun 16, 2023, at 6:23 PM, Thomas Kurz via fpc-pascal wrote: Whether it's elegant is a different question. In my opinion YES because it often gives better readable code than nested "if" statements inside the loop. But I've also read that using "break" is discouraged because it shows a bad choice of the loop range. This is highly suspect. Doing an early break in loops is the essence of how to do linear searching. No idea who thinks that's a bad idea. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal