Sign in Join
Wiki copytemporary

Infinite loop/fr: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Infinite loop/fr

OldNewLine
1+Une boucle infinie (aussi appelée boucle sans fin) est une boucle qui ne finit jamais.\$ Dans la boucle, les instructions sont répétées indéfiniment.
2+
3+``` pascal
4+ while true do
5+ begin
6+ end;
7+```
8+
9+``` pascal
10+ repeat
11+ until false;
12+```
13+
14+Toutefois, de telles constructions sont des cas particuliers, dans la pratique assez rares. Un exemple est une boucle d'interrogation d'événement dans les programmes avec IHM graphique. La présence d'une boucle infinie peut être le signe d'une erreur de programmation.
15+
16+## Instruction [[Break/fr|Break]]
17+
18+Les boucles "[[While/fr|While]] [[True/fr|True]] [[Do/fr|Do]]" ou "[[Repeat/fr]] [[Until/fr]] [[False/fr]]" semblent inifines au premier regard, mais il y a une manière de s'échapper de la boucle avec [[Break/fr|Break]].
19+
20+``` pascal
21+var
22+ i:integer;
23+begin
24+ i := 0;
25+ while true do
26+ begin
27+ i := i + 1;
28+ if i = 100 then break;
29+ end;
30+end;
31+```
32+
33+``` pascal
34+var
35+ i:integer;
36+begin
37+ i := 0;
38+ repeat
39+ i := i + 1;
40+ if i = 100 then break;
41+ until false;
42+end;
43+```
44+
45+Break est aussi permis dans les boucles [[For/fr/For]].
46+
47+## See also
48+
49+- [[True/fr|True]]
50+- [[False/fr|False]]
51+- [[Repeat/fr|Repeat]] [[Until/fr|Until]]
52+- [[While/fr|While]] [[Do/fr|Do]]
53+- [[Break/fr|Break]]
54+
55+---
56+*From the Free Pascal wiki, page "Infinite loop/fr", as it stood on 2020-02-17 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history