Sign in Join
Wiki copytemporary

datatype visibility: what changed

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

Title: datatype visibility

OldNewLine
1+Back to [[Data type|data types]].
2+
3+The visibility and thus the usability of data fields (eg of the type variable and constant) depends on the level of their publication.
4+
5+## Global level
6+
7+Data fields that are published in the interface section:
8+
9+Can be seen within the unit in which they were advertised. This means all procedures and functions of the unit can see and use these data fields.
10+
11+These data fields can also be seen by all units that include this unit under the uses clause. That means all procedures and functions that have integrated this unit can see these data fields and can use these data fields.
12+
13+## Module level
14+
15+Data fields published in the implementation section:
16+
17+Can only be seen within the unit in which they were published. This means all procedures and functions in the unit can see and use these data fields.
18+
19+## Subroutine level (procedures and functions)
20+
21+Data fields that are published in a subroutine:
22+
23+Can only be seen within the subroutine in which they were published. This means that these data fields can only be used in the subroutine in which they were published.
24+
25+``` pascal
26+ interface
27+ // data fields in this section are seen by each unit,
28+ // which includes this unit in its unit clause and
29+ // they are seen by the subroutines of this unit.
30+
31+ var
32+ ...;
33+ const
34+ ...;
35+
36+ implementation
37+ // Data fields in this section are only seen by the subroutines in this unit.
38+
39+ var
40+ ...;
41+ const
42+ ...;
43+
44+ procedure Example1();
45+ // Data fields that are published here are only seen by the subroutine
46+ var
47+ ...;
48+ const
49+ ...;
50+ begin
51+ ...;
52+ end;
53+
54+ function Example2() : Int64;
55+ // Data fields that are published here are only seen by the subroutine
56+ var
57+ ...;
58+ const
59+ ...;
60+ begin
61+ ...;
62+ end;
63+
64+ end.
65+```
66+
67+---
68+*From the Free Pascal wiki, page "datatype visibility", as it stood on 2020-02-12 after a change by Trev, 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).*

Back to history