Initialization: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Initialization
| Old | New | Line | |
|---|---|---|---|
| 1 | + | # Initialization of variables | |
| 2 | + | ||
| 3 | + | **Initialization** is the process by which an application sets the value of various internal variables, structures, tables, and other constructs which are used by the [[RTL|run-time library]] ("RTL"), or the [[operating system]]. | |
| 4 | + | ||
| 5 | + | Initialization and [[startup]] are two very similar practices, with the difference being that initialization is presumed to be the setting of values and data necessary for any program of any kind to start, while startup is the actions perfomed once a particular program is initialized. | |
| 6 | + | ||
| 7 | + | For example, a run-time library may need to obtain memory for internal [[buffer|buffers]], [[file handle|file handles]] (as used by the [[Input]] and [[Output]] [[standard files]]), [[window]] handles in a [[Graphical User Interface]], and other system resources. It may also, depending upon the operating system, load the user program or connect to [[shared library|shared libraries]]. It would, at that time, startup and transfer control to the user program, which would, itself, perform its own initialization. | |
| 8 | + | ||
| 9 | + | The difference between initialization and startup is that, in general, initialization is where a program sets up internal constants, tables and resources that are necessary for the program to operate, and without which, the program simply cannot continue. | |
| 10 | + | ||
| 11 | + | Startup would be the point at which an application is fully initialized, all the things that it needs to do only once have been done, and it essentially is ready to perform some work related to the problem definition that the application is intended to solve. Startup may also include non-initialization matters that need to be performed at the beginning of execution of an application. | |
| 12 | + | ||
| 13 | + | The main difference being that if a part of the startup of any program fails, the particular program should still continue to work, albeit possibly with degraded performance, while if initialization fails, the program cannot continue. | |
| 14 | + | ||
| 15 | + | # Initialization - reserved word in a unit | |
| 16 | + | ||
| 17 | + | **initialization** is also a [[Reserved words|reserved word]] within [[Object Pascal]]. It starts an optional initialization part of a [[Unit|unit]] and is terminated with [[End|end]] or an optional [[Finalization|finalization]] part of the [[Unit|unit]]. | |
| 18 | + | ||
| 19 | + | Back to [[Reserved words]]. | |
| 20 | + | ||
| 21 | + | ## Structure of a unit | |
| 22 | + | ||
| 23 | + | ``` pascal | |
| 24 | + | unit ...; // Name of the unit | |
| 25 | + | ||
| 26 | + | interface // Everything declared here may be used by this and other units (public) | |
| 27 | + | ||
| 28 | + | uses ...; | |
| 29 | + | ||
| 30 | + | ... | |
| 31 | + | ||
| 32 | + | implementation // The implementation of the requirements for this unit only (private) | |
| 33 | + | ||
| 34 | + | uses ...; | |
| 35 | + | ||
| 36 | + | ... | |
| 37 | + | ||
| 38 | + | initialization // Optional section: variables, data etc initialised here | |
| 39 | + | ||
| 40 | + | ... | |
| 41 | + | ||
| 42 | + | finalization // Optional section: code executed when the program ends | |
| 43 | + | ||
| 44 | + | ... | |
| 45 | + | end. | |
| 46 | + | ``` | |
| 47 | + | ||
| 48 | + | ## See also | |
| 49 | + | ||
| 50 | + | - [[Finalization]] | |
| 51 | + | - [[Implementation]] | |
| 52 | + | - [[Interface]] | |
| 53 | + | - [[Uses]] | |
| 54 | + | ||
| 55 | + | --- | |
| 56 | + | *From the Free Pascal wiki, page "Initialization", as it stood on 2020-02-15 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).* |
