Mode iso: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | [[FPC]]’s [[Compiler Mode|compatibility mode]] **`{$mode ISO}`** *intends* to comply with the requirements of level 0 and 1 of the ISO/IEC standard 7185. It became available in [[FPC New Features 2.6.0|version 2.6.0]]. The International Organization for Standardization standard 7185 is also known as [[Standard Pascal|Standard “Unextended” Pascal]]. | |
| 2 | 2 | ||
| 3 | 3 | ## Notable differences | |
| 4 | 4 | ||
| 5 | 5 | This list highlights differences to the standard [[Mode FPC|{$mode FPC}]] compiler compatibility mode. | |
| 6 | 6 | ||
| 7 | 7 | - `{$modeSwitch ISOProgramParas+}`: The [[Program|program]] parameter list becomes significant. If not enabled via the `‑MISO` command-line switch, you will need to place `{$mode ISO}` *before* the `program` header. | |
| 8 | 8 | - `{$modeSwitch ISOIO+}`: Files have associated “buffer variables” and [[Get|get]] and [[Put|put]] can operate on them. This functionality is not present in other modes. | |
| 9 | 9 | - `{$modeSwitch ISOUnaryMinus+}`: A unary [[Minus|minus]] has the same [[Operator|operator precedence]] as other addition operators. Usually *all* unary operators have the highest precedence. | |
| 10 | 10 | - `{$modeSwitch ISOMod+}`: The [[Mod|mod operator]] yields a positive result (Euclidean-like definition). | |
| 11 | 11 | - `{$modeSwitch nonLocalGoto+}`: You can [[Goto|goto]] labels anywhere in the program. | |
| 12 | 12 | - `{$modeSwitch nestedProcVars+}`: Procedural variables may assume addresses of nested [[Routine|routine]] definitions. | |
| 13 | 13 | - Support for routine parameters and `{$modeSwitch classicProcVars+}` (i. e. no special syntax requirements to differentiate between routine activation and designation): | |
| 14 | 14 | ||
| 15 | 15 | program routineParameter(output); | |
| 16 | 16 | ||
| 17 | 17 | procedure fancyPrint(function f: integer); begin | |
| 18 | 18 | ||
| 19 | 19 | ` writeLn('❧ ', f:1, ' ☙')` | |
| 20 | 20 | ||
| 21 | 21 | end; | |
| 22 | 22 | ||
| 23 | 23 | function getRandom: integer; begin | |
| 24 | 24 | ||
| 25 | 25 | ` { chosen by fair dice roll: guaranteed to be random }`\ | |
| 26 | 26 | ` getRandom := 4` | |
| 27 | 27 | ||
| 28 | 28 | end; | |
| 29 | 29 | ||
| 30 | 30 | begin | |
| 31 | 31 | ||
| 32 | 32 | ` fancyPrint(getRandom);` | |
| 33 | 33 | ||
| 34 | 34 | end. | |
| 35 | 35 | ||
| 36 | - | ||
| 37 | - | ||
| 38 | 36 | ## Status | |
| 39 | 37 | ||
| 40 | 38 | - As of version 3.2.0 the FPC does not yet support conformant-array parameters, thus level 1 requirements are not met, [FPC issue 38632](https://gitlab.com/freepascal.org/fpc/source/-/issues/38632). | |
| 41 | 39 | - It is not possible to mix block-comment delimiters. `{ }` and `(* *)` cannot be mixed although the standard specifically states so. | |
| 42 | 40 | ||
| 43 | 41 | ## Notes | |
| 44 | 42 | ||
| 45 | 43 | - The mode’s intention is to *at least* compile an ISO-compliant `program` [[Source code|source code]] file. The FPC will be able to compile a *superset* of programs. | |
| 46 | 44 | - For instance, ISO standard 7185 defines a *fixed order* of sections, [[Const|const]] → [[Type|type]] → [[Var|var]], but the FPC accepts *any* order, cf. [FPC issue 37739](https://gitlab.com/freepascal.org/fpc/source/-/issues/37739). | |
| 47 | 45 | - Delphi-style [[Comments|// end-of-line comments]] are accepted. | |
| 48 | 46 | - Or the mere fact that procedural *variables* are allowed should be surprising enough. | |
| 49 | 47 | ||
| 50 | 48 | ||
| 51 | 49 | It is quite possible that a *different* compiler rejects the same source code on grounds of non-compliance. Unlike the [[GNU Pascal]] Compiler there is no way to disable such “extensions”. | |
| 52 | 50 | ||
| 53 | 51 | - The value of the constant [[maxint|maxInt]] is not necessarily identical to `high(ALUSInt)`. The permissible range of values of the [[Integer|integer]] data type still depends on the mode. | |
| 54 | 52 | ||
| 55 | 53 | --- | |
| 56 | 54 | *From the Free Pascal wiki, page "Mode iso", as it stood on 2022-01-21 after a change by Alextp, 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).* |
