Mode iso

From Free Pascal wiki
Jump to navigationJump to search

English (en) français (fr) русский (ru)

FPC’s 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 version 2.6.0. The International Organization for Standardization standard 7185 is also known as Standard “Unextended” Pascal.

Notable differences

This list highlights differences to the standard {$mode FPC} compiler compatibility mode.

  • {$modeSwitch ISOProgramParas+}: The 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.
  • {$modeSwitch ISOIO+}: Files have associated “buffer variables” and get and put can operate on them. This functionality is not present in other modes.
  • {$modeSwitch ISOUnaryMinus+}: A unary minus has the same operator precedence as other addition operators. Usually all unary operators have the highest precedence.
  • {$modeSwitch ISOMod+}: The mod operator yields a positive result (Euclidean-like definition).
  • {$modeSwitch nonLocalGoto+}: You can goto labels anywhere in the program.
  • {$modeSwitch nestedProcVars+}: Procedural variables may assume addresses of nested routine definitions.
  • Support for routine parameters and {$modeSwitch classicProcVars+} (i. e. no special syntax requirements to differentiate between routine activation and designation):
     1{$mode ISO}
     2program routineParameter(output);
     3
     4procedure fancyPrint(function f: integer);
     5begin
     6	writeLn('❧ ', f:1, ' ☙')
     7end;
     8
     9function getRandom: integer;
    10begin
    11	{ chosen by fair dice roll: guaranteed to be random }
    12	getRandom := 4
    13end;
    14
    15begin
    16	fancyPrint(getRandom);
    17end.
    

Status

  • 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.
  • It is not possible to mix block-comment delimiters. { } and (* *) cannot be mixed although the standard specifically states so.

Notes

  • The mode’s intention is to at least compile an ISO-compliant program source code file. The FPC will be able to compile a superset of programs.
    • For instance, ISO standard 7185 defines a fixed order of sections, const → type → var, but the FPC accepts any order, cf. FPC issue 37739.
    • Delphi-style // end-of-line comments are accepted.
    • Or the mere fact that procedural variables are allowed should be surprising enough.
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”.
  • The value of the constant maxInt is not necessarily identical to high(ALUSInt). The permissible range of values of the integer data type still depends on the mode.