Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 4/Forward Referencing/ja

English · Français · Български · 中文(中国) · 日本語

4F - 前方参照 (著者: Tao Yue, 状態: 原文のまま変更なし)

難しいトピックが続いたが、ここでは簡単なことを話そう。

手続きや関数はすでに定義済みの変数やサブプログラムだけを見ることができたことを思いだそう。だが、ひとつ例外がある。

お互いが他方を呼び出している2つのサブプログラムがあるとすると、どちらを最初に置くべきかというジレンマが生じる。もう一方は最初のものからまだ呼び出せないからである。

この「卵が先か鶏が先か」問題をとくためには 前方参照 を使う。

pascal
procedure Later (parameter list); forward;

procedure Sooner (parameter list);
begin
  ...
  Later (parameter list);
end;
...
procedure Later;
begin
  ...
  Sooner (parameter list);
end;

関数も同様である。単にヘッディングの終わりに forward をつければ良い。

previous contents next

From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 4/Forward Referencing/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 WikiArchive .

Talk about this page

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