Sign in Join
Wiki copytemporary

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

Sent here from Punctuation and Indentation/ja.

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

1G - 区切りとインデント (著者: Tao Yue, 状態: 原文のまま)

Pascal は行末とスペースを無視するので文が終わったことをコンパイラに伝えるため区切り(punctuation)が必要になる。

以下の場合にはセミコロンをつけなくてはならない。

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)ブロックの間にあるような線)はスキップすればよい。現在のプログラミング環境(IED、あるいは統合開発環境)は Pascal の文法を理解し、タイプすればインデントしてくれることが多い。自分の好み(タブを3スペースあるいは4スペースにするなど)でインデントをカスタマイズすることができる。

適切なインデントはどうコードを働かせるかを決めるのを、よりたやすくしてくれる。だが、思慮深いコメントを加えれば、それはさらに大きな助けになるのである。

previous contents next

From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 1/Punctuation and Indentation/ja", 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 3 people, 2015–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
DerakunCreated page
Derakun
Derakun
Derakun
Derakun
TrevFixed syntax highlighting (minor)
Kai BurghardtKai Burghardt moved page Punctuation and Indentation/ja to Basic Pascal Tutorial/Chapter 1/Punctuation and Indentation/ja: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [... (minor)
Kai Burghardtbypass redirects [cf. discussion]
Kai Burghardtbypass [previously missed] redirect [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.