Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 1/Punctuation and Indentation/fr

Sent here from Punctuation and Indentation/fr.

한국어 · Deutsch · English · Français · Български · Русский · 中文(中国) · 日本語

Tutoriel de Pascal Objet : Bases / Ponctuation et indentation

Bien que Pascal ignore les fins de ligne et les espaces, la ponctuation est requise pour dire au compilateur quand une instruction se termine.

Vous devez avoir un point-virgule qui suit :

La dernière instruction dans un bloc BEGIN-END, celui qui précède le END ne nécessite pas de point-virgule. Néanmoins, il est prudent d'en ajouter au cas où vous auriez à déplacer l'instruction plus haut dans le bloc.

L'indentation n'est pas requise. Pourtant, c'est d'un usage répandu chez les développeurs puisqu'il rend les programmes plus clairs. Si vous le désirez, vous pouvez avoir un programme écrit comme ça :

pascal
program Stupid; const a=5; b=385.3; var alpha,beta:real; begin 
alpha := a + b; beta:= b / a end.

Mais il est bien plus agréable s'il est organisé comme ci-dessous :

pascal
program NotAsStupid;

const
  a = 5;
  b = 385.3;

var
  alpha,
  beta : real;

begin (* main *)
  alpha := a + b;
  beta := b / a;
end. (* main *)

De manière générale, indentez chaque bloc. Sautez une ligne entre les blocs (tel qu'entre les blocs const et var). Les environnements modernes de programmation (EDI : environnements de développement intégrés) comprennent la syntaxe du Pascal et indenteront souvent à votre place ce que vous saisissez. Vous pouvez personnaliser l'indentation selon vos préférences (afficher une tabulation avec trois espaces ou quatre ?).

Une indentation appropriée rend plus facile la détermination de ce que fait le code mais elle est largement aidée par des commentaires judicieux.


From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 1/Punctuation and Indentation/fr", as it stood on 2022-08-20 after a change by Kai Burghardt, 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.

Revision 1, last changed by Kai Burghardt .

Edited on wiki.freepascal.org by 5 people, 2014–2022

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
E-ricCreated page
E-ric (minor)
FTurtle
FrigoryRefonte
FrigoryRetouhes
TrevFixed syntax highlighting (minor)
TrevText replacement - "Object Pascal Tutorial" to "Basic Pascal Tutorial" (minor)
Kai BurghardtKai Burghardt moved page Punctuation and Indentation/fr to Basic Pascal Tutorial/Chapter 1/Punctuation and Indentation/fr: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [... (minor)
Kai Burghardtbypass redirects [cf. discussion]
Kai Burghardtbypass language bar/categorization template redirect [cf. discussion] (minor)

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.