Hint Directives: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Hint Directives
| Old | New | Line | |
|---|---|---|---|
| 1 | + | ## Using Hint Directives | |
| 2 | + | ||
| 3 | + | Whenever an identifier marked with a hint directive is later encountered by the compiler, then a warning will be displayed, corresponding to the specified hint. | |
| 4 | + | ||
| 5 | + | - **deprecated** | |
| 6 | + | - The use of this identifier is deprecated, use an alternative instead. The deprecated keyword can be followed by a string constant with a message. The compiler will show this message whenever the identifier is encountered. | |
| 7 | + | ||
| 8 | + | - **experimental** | |
| 9 | + | - The use of this identifier is experimental: this can be used to flag new features that should be used with caution. | |
| 10 | + | ||
| 11 | + | - **platform** | |
| 12 | + | - This is a platform-dependent identifier: it may not be defined on all platforms. | |
| 13 | + | ||
| 14 | + | - **unimplemented** | |
| 15 | + | - This should be used on functions and procedures only. It should be used to signal that a particular feature has not yet been implemented. | |
| 16 | + | ||
| 17 | + | The following are examples: | |
| 18 | + | ||
| 19 | + | ``` pascal | |
| 20 | + | Const | |
| 21 | + | AConst = 12 deprecated; | |
| 22 | + | ||
| 23 | + | var | |
| 24 | + | p : integer platform; | |
| 25 | + | ||
| 26 | + | Function Something : Integer; experimental; | |
| 27 | + | ||
| 28 | + | begin | |
| 29 | + | Something:=P+AConst; | |
| 30 | + | end; | |
| 31 | + | ||
| 32 | + | begin | |
| 33 | + | Something; | |
| 34 | + | end. | |
| 35 | + | ``` | |
| 36 | + | ||
| 37 | + | This would result in the following output: | |
| 38 | + | ||
| 39 | + | ```text | |
| 40 | + | testhd.pp(11,15) Warning: Symbol "p" is not portable | |
| 41 | + | testhd.pp(11,22) Warning: Symbol "AConst" is deprecated | |
| 42 | + | testhd.pp(15,3) Warning: Symbol "Something" is experimental | |
| 43 | + | ``` | |
| 44 | + | ||
| 45 | + | Hint directives can follow all kinds of identifiers: units, constants, types, variables, functions, procedures and methods. | |
| 46 | + | ||
| 47 | + | --- | |
| 48 | + | *From the Free Pascal wiki, page "Hint Directives", as it stood on 2020-06-23 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).* |
