Sign in Join
Wiki copytemporary

Revision 1 of 1, by Kai Burghardt on 8-20-2022. The page as it is now.

Basic Pascal Tutorial/Chapter 4/Forward Referencing/ja

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.