[fpc-pascal] Legitimate use of for and break

Sven Barth pascaldragon at googlemail.com
Mon Jun 19 22:17:11 CEST 2023


Am 18.06.2023 um 19:28 schrieb Travis Siegel via fpc-pascal:
>
> On 6/18/2023 1:04 AM, Hairy Pixels via fpc-pascal wrote:
>> 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.
>
> Use a variable, set the variable when you hit an exit criteria, then 
> before repeating the loop, check the variable, if it's true, exit the 
> loop (exit does this), or just craft the loop (easy to do if it's a 
> loop until construct) so it exits the loop automatically.  Probably 
> not as efficient as break, but since I didn't know it was a valid 
> command, <shrug>

“Exit” leaves the surrounding *function*, not the surrounding *loop*.

Regards,
Sven


More information about the fpc-pascal mailing list