Sign in Join
Wiki copytemporary

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

Sent here from Punctuation and Indentation/ru.

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

Пунктуация и отступы

1G - Punctuation and Indentation (author: Tao Yue, state: unchanged)

Поскольку Pascal игнорирует переводы строк и пробелы, пунктуация должна сообщить компилятору, где заканчивается оператор.

Места, где вы должны иметь точку с запятой:

Последний оператор в блоке BEGIN-END, непосредственно предшествующий END, не требует точки с запятой. Однако, будет гораздо лучше поставить её, поскольку это избавит вас от необходимости добавлять её, если вдруг понадобится переместить оператор выше.

Отступы не являются обязательными. Однако, они очень полезны для программиста, поскольку помогают сделать программу более понятной. Если вы захотите, вы можете иметь программу, которая выглядит так:

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

Но будет гораздо лучше, если она будет выглядеть так:

pascal
program NotAsStupid;

const
  a = 5;
  b = 385.3;

var
  alpha,
  beta : real;

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

В общем, делайте отступ для каждого блока. Пропускайте строку между блоками (например, между блоками const и var). Современные среды разработки (IDE - Integrated Development Environment) понимают синтаксис Pascal и часто сами будут делать отступы для вас во время набора текста. Вы можете настроить отступы по своему вкусу (количество пробелов на табуляцию).

Правильные отступы позволяют гораздо легче разобраться, как работает код, чему также очень помогает разумное комментирование.


From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 1/Punctuation and Indentation/ru", 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 2, last changed by Kai Burghardt .

Edited on wiki.freepascal.org by 3 people, 2016–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
FTurtleCreated page
TrevFixed syntax highlighting (minor)
Kai BurghardtKai Burghardt moved page Punctuation and Indentation/ru to Basic Pascal Tutorial/Chapter 1/Punctuation and Indentation/ru: 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.