Mode iso: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Mode iso
| Old | New | Line | |
|---|---|---|---|
| 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 | + | ||
| 3 | + | ## Notable differences | |
| 4 | + | ||
| 5 | + | This list highlights differences to the standard [[Mode FPC|{$mode FPC}]] compiler compatibility mode. | |
| 6 | + | ||
| 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 | + | - `{$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 | + | - `{$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 | + | - `{$modeSwitch ISOMod+}`: The [[Mod|mod operator]] yields a positive result (Euclidean-like definition). | |
| 11 | + | - `{$modeSwitch nonLocalGoto+}`: You can [[Goto|goto]] labels anywhere in the program. | |
| 12 | + | - `{$modeSwitch nestedProcVars+}`: Procedural variables may assume addresses of nested [[Routine|routine]] definitions. | |
| 13 | + | - Support for routine parameters and `{$modeSwitch classicProcVars+}` (i. e. no special syntax requirements to differentiate between routine activation and designation): | |
| 14 | + | ||
| 15 | + | program routineParameter(output); | |
| 16 | + | ||
| 17 | + | procedure fancyPrint(function f: integer); begin | |
| 18 | + | ||
| 19 | + | ` writeLn('❧ ', f:1, ' ☙')` | |
| 20 | + | ||
| 21 | + | end; | |
| 22 | + | ||
| 23 | + | function getRandom: integer; begin | |
| 24 | + | ||
| 25 | + | ` { chosen by fair dice roll: guaranteed to be random }`\ | |
| 26 | + | ` getRandom := 4` | |
| 27 | + | ||
| 28 | + | end; | |
| 29 | + | ||
| 30 | + | begin | |
| 31 | + | ||
| 32 | + | ` fancyPrint(getRandom);` | |
| 33 | + | ||
| 34 | + | end. | |
| 35 | + | ||
| 36 | + | </syntaxhighlight> | |
| 37 | + | ||
| 38 | + | ## Status | |
| 39 | + | ||
| 40 | + | - 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 | + | - It is not possible to mix block-comment delimiters. `{ }` and `(* *)` cannot be mixed although the standard specifically states so. | |
| 42 | + | ||
| 43 | + | ## Notes | |
| 44 | + | ||
| 45 | + | - 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 | + | - 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 | + | - Delphi-style [[Comments|// end-of-line comments]] are accepted. | |
| 48 | + | - Or the mere fact that procedural *variables* are allowed should be surprising enough. | |
| 49 | + | ||
| 50 | + | ||
| 51 | + | 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 | + | ||
| 53 | + | - 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 | + | ||
| 55 | + | --- | |
| 56 | + | *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).* |
