Mode iso
From Lazarus 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+}
: Theprogram
parameter list becomes significant. If not enabled via the‑MISO
command-line switch, you will need to place{$mode ISO}
before theprogram
header.{$modeSwitch ISOIO+}
: Files have associated “buffer variables” andget
andput
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+}
: Themod
operator yields a positive result (Euclidean-like definition).{$modeSwitch nonLocalGoto+}
: You cangoto
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):{$mode ISO} program routineParameter(output); procedure fancyPrint(function f: integer); begin writeLn('❧ ', f:1, ' ☙') end; function getRandom: integer; begin { chosen by fair dice roll: guaranteed to be random } getRandom := 4 end; begin fancyPrint(getRandom); end.
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.
- For instance, ISO standard 7185 defines a fixed order of sections,
- 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”.