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
editThis list highlights differences to the standard {$mode FPC} compiler compatibility mode.
{$modeSwitch ISOProgramParas+}: Theprogramparameter list becomes significant. If not enabled via the‑MISOcommand-line switch, you will need to place{$mode ISO}before theprogramheader.{$modeSwitch ISOIO+}: Files have associated “buffer variables” andgetandputcan 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+}: Themodoperator yields a positive result (Euclidean-like definition).{$modeSwitch nonLocalGoto+}: You cangotolabels 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
edit- As of version 3.2.0 the FPC does not yet support conformant-array parameters, thus level 1 requirements are not met, fpc/source/-/issues/38632 FPC issue 38632.
- It is not possible to mix block-comment delimiters.
{ }and(* *)cannot be mixed although the standard specifically states so.
Notes
edit- The mode’s intention is to at least compile an ISO-compliant
programsource 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/source/-/issues/37739 FPC issue 37739. - Delphi-style
// end-of-line commentsare 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”.