Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 4/Forward Referencing: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-4F - Forward Referencing (author: Tao Yue, state: unchanged)
2-
3-After all these confusing topics, here's something easy.
1+[[Basic Pascal Tutorial/Chapter 4/Recursion|◄]] | [[Basic Pascal Tutorial/Contents|▲]] | [[Basic Pascal Tutorial/Chapter 4/Programming Assignment|►]]
2+---|---|---
3+
4+4F - Forward Referencing (author: Tao Yue, state: unchanged)
45
5-Remember that procedures/functions can only see variables and other subprograms that have already been defined? Well, there is an exception.
6+After all these confusing topics, here's something easy.
67
7-If you have two subprograms, each of which calls the other, you have a dilemma that no matter which you put first, the other still can't be called from the first.
8+Remember that procedures/functions can only see variables and other subprograms that have already been defined. Well, there is an exception.
89
9-To resolve this chicken-and-the-egg problem, use *forward referencing*.
10+If you have two subprograms, each of which calls the other, you have a dilemma that no matter which you put first, the other still can't be called from the first.
1011
11-``` pascal
12+To resolve this chicken-and-the-egg problem, use _forward referencing_.
13+```
1214procedure Later (parameter list); forward;
13-
14-procedure Sooner (parameter list);
15-begin
16- ...
17- Later (parameter list);
18-end;
19-...
20-procedure Later;
21-begin
22- ...
23- Sooner (parameter list);
24-end;
15+
16+ procedure Sooner (parameter list);
17+ begin
18+ ...
19+ Later (parameter list);
20+ end;
21+ ...
22+ procedure Later;
23+ begin
24+ ...
25+ Sooner (parameter list);
26+ end;
2527```
2628
27-The same goes for functions. Just stick a forward; at the end of the heading.
29+The same goes for functions. Just stick a forward; at the end of the heading.
2830
31+[[Basic Pascal Tutorial/Chapter 4/Recursion|◄]] | [[Basic Pascal Tutorial/Contents|▲]] | [[Basic Pascal Tutorial/Chapter 4/Programming Assignment|►]]
32+---|---|---
33+
2934---
30-*From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 4/Forward Referencing", 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](/wiki-contact).*
35+*From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 4/Forward Referencing", as the Internet Archive kept it on 2025-04-01, last changed on 2025-03-02. 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](/wiki-contact).*

Back to history