Node:Miscellaneous, Next:BP and Extended Pascal, Previous:Special Parameters, Up:Borland Pascal

### Miscellaneous

- Headlines: According to Extended Pascal, a program headline must contain the program's parameters:

      program Foo (Input, Output);
      begin
      end.

  In GNU Pascal, headline parameters are optional. If the headline is omitted entirely, a warning is given unless you have specified `--borland-pascal` in the command line.

- `case` statements: In a `case` statement, GNU Pascal allows `otherwise` (according to Extended Pascal) as an alternative to `else`:

      program CaseOtherwiseDemo;
      var x: Integer;
      begin
        ReadLn (x);
        case x of
          1: WriteLn ('one');
          2: WriteLn ('two');
          otherwise
             WriteLn ('many')
        end
      end.

  Note: In the absence of a `case` or `otherwise` branch, missing cases labels cause an error in Extended Pascal (which goes unnoticed in Borland Pascal). GPC does not give this error, but a warning if the `-Wswitch` option is given, however only for enumeration types.

- Character constants: BP compatible character constants like `^M` as well as `#13` are implemented into GNU Pascal.
- Sets: GNU Pascal has a `Card` function for sets which counts their elements. Unlike Borland Pascal, GNU Pascal does not limit sets to the range 0 .. 255.
- Inline: GNU Pascal allows "inline" Pascal procedures and functions, while Borland Pascal only allows machine code to be inlined:

  Borland Pascal:

      function Max (x, y: Integer): Integer;
        inline ($58 / $59 / $3b / $c1 / $7f / $01 / $91);

  GNU Pascal:

      program InlineDemo;

      function Max (x, y: Integer): Integer; attribute (inline);
      begin
        if x > y then
          Max := x
        else
          Max := y
      end;

      begin
        WriteLn (Max (42, 17), ' ', Max (-4, -2))
      end.

  (Actually, a more general `Max` function is already built in.)

  This feature is not so important as it might seem because in optimization level 3 or higher (see GPC Options), GNU Pascal automatically inlines short procedures and functions.