[fpc-pascal] Forward declarations
Mattias Gaertner
nc-gaertnma at netcologne.de
Thu Dec 22 21:57:01 CET 2011
On Thu, 22 Dec 2011 15:33:13 -0500
Timothy Groves <the.tail.kinker at gmail.com> wrote:
> Can anyone think of a situation in which you would *have* to use forward
> declared functions? I'm trying to come up with an example for such for
> my book, and I am drawing a blank.
Traverse a html tree. For example with div and p nodes. Both div and
p nodes can have children that are div and p nodes.
procedure Proc(RootNode: TNode);
procedure ReadChildrenv(Node: TNode); forward;
procedure ReadP(Node: TNode);
begin
...
ReadChildren(Node);
end;
procedure ReadDiv(Node: TNode);
begin
...
ReadChildren(Node);
end;
procedure ReadChildren(Node: TNode);
begin
for Child in Node do begin
if Child is Div then ReadDiv(Child)
else if Child is P then ReadP(Child);
end;
end;
begin
ReadChildren(RootNode);
end;
Mattias
More information about the fpc-pascal
mailing list