@c File: bpqstart.texi; Author: Peter Gerwinski <peter@gerwinski.de>
@c Created on: 31. July 1996; last modification:  2. Aug. 1996

@node Borland Pascal
@chapter From Borland Pascal to GNU Pascal

This chapter is intended to be a QuickStart guide for programmers
who are familiar with Borland Pascal, version 7 for DOS
protected mode.  Other versions don't differ too much but this
one is the very last DOS version Borland has published.

@menu
* Borland compatibility::
* IDE versus command line::
* Comments and compiler directives::
* Units; GPI files and AutoMake::
* Optimization::
* Debugging::
* GPC inline assembler::
* Objects::
* Strings::
* Typed constants::
* Bit; byte and memory manipulation::
* User-defined operators in GPC::
* Data types in BP and GPC::
* Files::
* Built-in constants::
* Built-in operators in BP and GPC::
* Built-in Procedures and Functions::
* Parameters::
* Miscellaneous::
@end menu

@c ----------------------------------------------------------------------------

@node Borland compatibility
@section Borland compatibility

Unlike other free compilers, GNU Pascal is @strong{not} intended
to be 100% Borland compatible.  GNU Pascal is part of the GNU project,
so portability between different machines is one of its primary goals.
For this reason, non-portable features of Borland Pascal will probably
not be included into GNU Pascal.  Some other differences are so minimal
that we have more important things to do than to implement them.

However if you want to contribute to GNU Pascal by eliminating holes in
GPC's Borland compatibility, be welcome in the GNU Pascal development
team!  See @ref{How to Contribute} for details.

@c ----------------------------------------------------------------------------

@node IDE versus command line
@section IDE versus command line

On the DOS platform with DJGPP, you can use the RHIDE for GNU Pascal;
check the subdirectories of your DJGPP distribution.

Unfortunately, there is no IDE which would run on all platforms.  We are
working on it, but this will take some time.  Please be patient---or
offer your help!

Without an IDE, the GNU Pascal Compiler, GPC, is called about like the
command-line version of the Borland Pascal Compiler, BPC.  Edit your
source file(s) with your favorite ASCII editor, then call GNU Pascal
with a command line like

@smallexample
  C:\GNU-PAS> gpc hello.pas -o hello.exe
@end smallexample

@noindent on your DOS or OS/2 box or

@smallexample
  myhost/home/joe/gnu-pascal> gpc hello.pas -o hello
@end smallexample

@noindent on your UNIX (or UNIX-compatible) system.  Don't omit the suffix
@samp{.pas}:  GPC is a common interface for a Pascal compiler, a C, ObjC
and C++ compiler, an assembler, a linker, and perhaps a Modula and
FORTRAN compiler.  From the extension of your source file GPC figures
out which compiler to run.

The @code{-o} is a command line option which tells GPC how the
executable has to be named.  If not given, the executable will
be called @samp{a.out} (Unix) or @samp{a.exe} (Dos).

Note that GPC is case-sensitive concerning file names, so it
will @emph{not} work if you type

@smallexample
  C:\GNU-PAS> GPC HELLO.PAS -O HELLO.EXE
@end smallexample

GPC is a very quiet compiler and doesn't print anything on the
screen unless you request it or there is an error.  If you want
to see what is going on, invoke GPC with additional options:

@smallexample
  -Q            "don't be quiet"  (or: Quassel-Modus in German)
@end smallexample

@noindent (with @emph{capital} @samp{Q}!) means that GPC prints out the
names of procedures and functions it processes, and

@smallexample
  --verbose
@end smallexample

or abbreviated

@smallexample
  -v
@end smallexample

@noindent means that GPC informs you about the stages of compilation, i.e.
preprocessing, compiling, assembling, and linking.

One example (this time for OS/2):

@smallexample
  [C:\GNU-Pascal] gpc --verbose -Q hello.pas
@end smallexample

Throughout this chapter, we will tell you about a lot of
command-line switches.  They are all invoked this way.

After compilation, there will be an executable @code{hello} file in
the current directory.  (@code{hello.exe} with DOS and OS/2.)  Just
run it and enjoy.  If there are errors, GNU Pascal will not stop
compilation after the first one---as Borland Pascal does---but
try to catch them all in one compilation.  If you get more error
messages than your screen can hold, you can catch them in a file
(e.g.@: @code{gpc.out}) or pipe them to a program like @samp{more}
in the following way:

@smallexample
  gpc hello.pas 2>gpc.out
@end smallexample

This works with OS/2 and any bash-like shell under UNIX; for DOS
you must get a replacement for @code{command.com} which supports
this kind of redirection, or use the @samp{redir} utility
(see also the DJGPP FAQ):

@smallexample
  C:\GNU-PAS> redir -eo gpc hello.pas -o hello.exe | more
@end smallexample

You can also use Borland's IDE for GNU Pascal on the DOS platform:
Install the GNU Pascal Compiler in the Tools menu (via Options/Tools).

@smallexample
  Name:       GNU Pascal
  Path:       gpc
  Arguments:  $SAVE ALL --verbose -Q $NAME($EDNAME).pas
  HotKey:     Shift+F9
@end smallexample

Note once more that GPC is case-sensitive, so it is important to
specify @code{.pas} instead of the @code{.PAS} Borland Pascal would 
append otherwise!

You can include more command-line arguments to GNU Pascal (e.g.@:
@samp{--automake}; see below) as you will learn more about them.

Since Borland Pascal will try to recompile your program if you
use its @code{run} menu function, you will need another ``tool''
to run your program:

@smallexample
  Name:       run program
  Path:       command.com
  Arguments:  /c $NAME($EDNAME)
  HotKey:     Shift+F10
@end smallexample

@c ----------------------------------------------------------------------------

@node Comments and compiler directives
@section Comments and compiler directives

According to ISO 7185 and ISO 10206 standard, GNU Pascal can recognize
comments opened with @code{(*} and closed with @code{@}}.  With Borland
Pascal, both types of comments can be nested, so you will probably have
sources where passages containing comments are ``commented out''.  GPC's
default behavior is to allow nested comments, so you don't need to worry
about this.  However you can switch it off either by a command-line
option, or by a compiler directive:

@smallexample
  --no-nested-comments     @{$N-@}    (*$N-*)
@end smallexample

The $N directive also exists in BP but has another meaning.
The same holds for most of GPC's other compiler directives
(also corresponding to command-line options in most cases):

@example
  --short-circuit     $B+ $B-  like in Borland Pascal:
                               $B- means short-circuit Boolean
                               operators; $B+ complete evaluation

  --c-numbers         $C+ $C-  enable/disable C-style octal 0177
                               and hexadecial 0xFF numbers

  --char-escapes      $E+ $E-  enable/disable C-style character
                               escape sequences in strings

  --nested-comments   $N+ $N-  see above

  --pedantic          $P+ $P-  give/don't give portability warnings

                      $W+ $W-  enable/disable warnings

                      $X+ $X-  enable/disable extended syntax
                               (function return value ignore,
                               operator definitions, ``PChars'',
                               pointer arithmetics, ...)

  --borland-pascal             disable or warn about GPC features
                               not supported by Borland Pascal;
                               do not warn about ``dangerous'' BP
                               features

  @{$I FileName @}               include filename.pas or
                               filename.p (make it lowercase)

  @{$include "filename.pas"@}    include (case-sensitive)

  @{$include <filename.pas>@}    the same, but don't search in
                               current directory

  @{$M Hello!@}                  write message "Hello!" to error
                               device during compilation

  @{$D GNU@}                     define GNU (for conditional
  @{$define GNU@}                compilation)

  -D GNU                       the same in command line

  @{$D loop while true do@}      define "loop" to be "while
                               true do" as a macro like in C.
                               The name of the macro is case-sensitive.

  @{$ifdef GNU@}                 conditional compilation
    ...                        (like in Borland Pascal).
  @{$else@}                      GPC predefines the symbol
    ...                        __GPC__ (with two leading
  @{$endif@}                     and trailing underscores).
@end example

You also can use C-style preprocessor directives, e.g.@: @samp{#include.},
but this is deprecated, e.g. because of possible conflicts with
Borland Pascal style @samp{#42} character constants.

As in Borland Pascal, @code{@{$...@}} and @code{(*$...*)} are equivalent.

@c ----------------------------------------------------------------------------

@node Units; GPI files and AutoMake
@section Units, GPI files and AutoMake

You can use Units in the same way as in Borland Pascal.
However, there are some differences, problems and new features.
(Please report the bug if something doesn't work.)

Concerning the syntax of a Unit, you can, if you want, use
Extended Pascal syntax to specify a Unit initializer, i.e.
instead of writing

@smallexample
  begin
    ...
  end.
@end smallexample

@noindent at the end of the Unit, you can get the same result with

@smallexample
  to begin do
    begin
      ...
    end (* to begin *);
@end smallexample

@noindent and there also exists

@smallexample
  to end do
    begin
      ...
    end (* to end *);
@end smallexample

which specifies a finalization routine.  You can use this instead of
Borland Pascal's exit procedures, but for compatibility the included
@samp{system} unit also provides the @samp{ExitProc} variable.
In @ref{Extensions} and @ref{Extended Pascal}, you can find
information about Extended Pascal Modules, an alternative to
Units.

At the moment, there are no qualified identifiers, so take care
about name clashes between different Units.

When GPC compiles a Unit, it produces two files: an @code{.o} object
file (compatible with other GNU compilers such as GNU C) plus a
precompiled Interface which resides in a @code{.gpi} file.
@ifset INTERNALS
(See @ref{GPI files} for GPI file internals.)
@end ifset

GPC does not automatically recognize that something is a Unit
and cannot be linked; you have to tell this by a command line
switch:

@smallexample
  -c            only compile, don't link.
@end smallexample

For example, to compile two units, use:

@smallexample
  gpc -c myunit1.pas myunit2.pas
@end smallexample

Of course, one of the purposes of writing Units is to compile
them separately.  However, GNU Pascal allows you to have one or
more Units in the same source file (producing only one @code{.o} file
but separate @code{.gpi} files).  You even can have a Program and Units
in one and the same source file; in this case, no @code{.o} file is
produced at all.

When you have all Units compiled and want to compile the
Program, specify the @code{.o} files in the command line:

@smallexample
  gpc hello.pas myunit1.o myunit2.o
@end smallexample

You also can specify the program and the units in one command
line:

@smallexample
  gpc hello.pas myunit1.pas myunit2.pas
@end smallexample

As an alternative to manually compiling and specifying object files, you
can use GPC's AutoMake feature.  (@strong{Warning}: This is a new feature
in GPC 2.0 and may be unstable!)  With an additional command-line argument

@smallexample
  gpc --automake hello.pas
@end smallexample

GPC tries to behave like Borland Pascal's @code{make} facility and
automatically recompiles Units the source of which has been
changed.  It also works if an included file has been changed.

@ifset INTERNALS
For more information about the AutoMake mechanism, see
@ref{AutoMake}.
@end ifset

@c ----------------------------------------------------------------------------

@node Optimization
@section Optimization

GNU Pascal is a 32 bit compiler with excellent optimization
algorithms (which are identically the same as those of GNU C).
There are three optimization levels, specified by the command line
options @samp{-O}, @samp{-O2}, and @samp{-O3}.  (Levels up to
@samp{-O6} are worked on.)

One example:

@smallexample
  Program Test;

  procedure Foo;
  Var
    A, B: Integer;
  begin
    A:= 3;
    B:= 4;
    writeln ( A + B );
  end;

  begin
    Foo
  end.
@end smallexample

When GNU Pascal compiles this program with optimization, it
recognizes that the argument of writeln is the constant 7---and
optimizes away the variables @code{A} and @code{B}. If the variables
were global, they would not be optimized away because they might be
accessed from other places, but the constant 7 would still be
optimized.

For more about optimization, see the GNU C documentation.

@c ----------------------------------------------------------------------------

@node Debugging
@section Debugging

The command line option @samp{-g} specifies generation of debugging
information for GDB, the GNU debugger.  GDB is not as comfortable as the
Turbo Debugger, but it has the same abilities but one:  The program being
debugged is slowed down.  For more information about GDB, call it (with
@samp{gdb}) and type in the @code{help} command.

GDB has one very nice feature which might even make up for the
slowing-down problematic:  When a GNU-compiled program crashes,
it puts out a @code{core} file.  When you say ``target core core'' to
the GNU debugger, it reads the core file and can tell you the
address of the crash, the contents of variables and of the
stack, and so on.

Sometimes it is nice to have a look at the assembler output of
the compiler.  When you specify the @code{-S} command line option, GPC
produces an @code{.s} file instead of an @code{.o} file which contains
assembler source for your program.  More about this in the next
section.

See also ``Notes for debugging'' in the ``Bugs'' chapter; see @ref{GPC bugs}.

@c ----------------------------------------------------------------------------

@node GPC inline assembler
@section GPC inline assembler

GNU Pascal has an inline assembler, but it is quite different
from Borland's one.  I have not yet found reasonable
documentation about the use of this assembler, but I found out
the following:

The syntax is

@smallexample
  asm ( 'movl $12345678, %eax' );
  asm ( 'movl %eax, %edx' );
@end smallexample

to move the (hex) value @samp{$12345678} to the EAX register and then
to the EDX register.  The String argument of the asm statement
is passed as a string to the assembler stage of the compilation.
The assembler follows the AT&T, not the Intel syntax.  Note that the
order of operands is reversed with respect to the order you know from
Intel assemblers and that the size of the arguments is appended to the
mnemonic as a suffix b (byte), w (word = 2 bytes), or l (long = 4
bytes).

You can learn about the GNU assembler syntax when compiling your
program with @samp{-S} (see above) and looking into the resulting
assembler source.

To access Pascal symbols from the assembler, do something like

@smallexample
  asm ( 'movl %%eax, %0' : : 'rm' ( MyVariable ) );
@end smallexample

Here, the % signs in front of the register names are doubled
because % gets some special meaning.  The 'rm' means that the
operand may be in a register or in memory.

(More about this is in preparation.)

@c ----------------------------------------------------------------------------

@node Objects
@section Objects

Objects in the Borland Pascal 7.0 notation are implemented into
GNU Pascal with the following differences:

@cindex foo
@itemize @bullet
@item the "private" directive does not work,
@item data fields and methods may be mixed:
@smallexample
  MyObj = object
    x: Integer;
    Procedure Foo; virtual;
    y: Real;
    Function Bar: Char;
  end (* MyObj *);
@end smallexample
@end itemize

@c ----------------------------------------------------------------------------

@node Strings
@section Strings

Strings are ``Schema types'' in GNU Pascal which is something more
complicated than Borland-style strings.  For variables, you
cannot specify just @code{String} as a type like in Borland Pascal;
for parameters and pointer types you can.  There is no 255 characters
length limit.  According to Extended Pascal, the maximum string
length must be in (parantheses); GNU Pascal accepts [brackets], too,
however.

For more about Strings and Schema types see @ref{Extensions} and
@ref{Extended Pascal}.

GPC supports Borland Pascal's String-handling functions and some
more (see @ref{Extensions}):

@smallexample
  Borland Pascal       GNU Pascal

  Length               Length
  Pos                  Pos, Index (1)
  Str                  Str, WriteStr (1)
  Val                  Val, ReadStr
  Copy                 Copy, SubStr, MyStr [ 2 .. 7 ] (2)
  MyStr [ 0 ]:= #7;    SetLength
    -                  Trim
  =, <>, <, <=, >, >=  =, <>, <, <=, >, >=
    -                  EQ, NE, LT, LE, GT, GE
  Insert               Insert
  Delete               Delete
@end smallexample

(1) the order of parameters of the Borland Pascal vs. Extended Pascal
    routines is different

(2) @samp{SubStr} reports a runtime error if the requested substring
    does not fit in the given string, @samp{Copy} does not

@c ----------------------------------------------------------------------------

@node Typed constants
@section Typed constants

GNU Pascal supports Borland Pascal's ``typed constants'' but also
Extended Pascal's initialized variables:

@smallexample
  Var
    x: Integer value 7;
@end smallexample

or

@smallexample
  Var
    x: Integer = 7;
@end smallexample

When a typed constant is misused as an initialized variable, a
warning is given unless you specify @samp{--borland-pascal}.

When you initialize a record, you may omit the field names.  When you
initialize an array, you may provied indices with a @code{:}.  However
this additional information is ignored completely, so perhaps it's best
for the moment only to provide the values @dots{}

When you want a local variable to preserve its value, define it
as @samp{static} instead of using a typed constant. Typed constants
also become static automatically for Borland Pascal compatibility,
but it's better not to rely on this ``feature'' in new programs.

@cindex foo
@smallexample
  Procedure Foo;

  Var
    x: static Real;

  begin (* Foo *)
    (* x keeps its value between two calls to this Procedure *)
  end (* Foo *);
@end smallexample

@c ----------------------------------------------------------------------------

@node Bit; byte and memory manipulation
@section Bit, byte and memory manipulation

The (non-standard) bitwise operators @samp{shl}, @samp{shr}, 
@samp{and}, @samp{or}, @samp{xor} work in GNU Pascal like 
in Borland Pascal.  As an extension, you can
use them as ``procedures'', for examples

@smallexample
  and ( x, $0000FFFF );
@end smallexample

as an alternative to

@smallexample
  x:= x and $0000FFFF;
@end smallexample

GPC accepts the Borland-specific notation @samp{$ABCD} for hexadecimal
numbers, but you also can use Extended Pascal notation:

@smallexample
   2#11111111   for a binary,
   8#177        for an octal,
  16#FF         for a hexadecimal number,
@end smallexample

and so on up to a basis of 36.

@samp{Inc} and @samp{Dec} are implemented like in Borland Pascal;
@samp{Pred} and @samp{Succ} are generalized according to Extended Pascal:

@smallexample
  a:= Succ ( a, 5 );
@end smallexample

@samp{Absolute} variables work in the context of overloading with
other variables as well as in the context of specifying an absolute address,
but the latter is highly unportable and not very useful even in DOS
protected mode.

The @samp{Mem} and @samp{Port} arrays don't exist in GNU Pascal.
As a replacement for @samp{Port}, you can use routines like those
provided in the @samp{Ports} unit.

Borland Pascal's procedures @code{FillChar} and @code{Move} are
built-in into GNU Pascal.

@c ----------------------------------------------------------------------------

@node User-defined operators in GPC
@section User-defined operators in GPC

GNU Pascal allows the user to define operators according to the
Pascal-SC syntax:

@smallexample
  Type
    Point = record
      x, y: Real;
    end (* Point *);

  Operator + ( a, b: Point ) c: Point;

  begin (* Point + Point *)
    c.x:= a.x + b.x;
    c.y:= a.y + b.y;
  end (* Point + Point *);
@end smallexample

The Pascal-SC operators @samp{+>}, @samp{+<}, etc.@: for exact numerical
calculations are not implemented, but you can define them.
If you write a module which really implements these operators,
please send it to us, so we can include it into the next
distribution.

(And if you know more about modules in Pascal-SC than just their
existence, please contact us as well!  We could probably easily
implement them if we knew how they look like.  Something quite
close to Pascal-SC modules already @emph{is} implemented as ``GNU
specific modules''.)

@c ----------------------------------------------------------------------------

@node Data types in BP and GPC
@section Data types in BP and GPC

@itemize @bullet
@item
Integer types have different sizes in Borland and GNU Pascal:

@smallexample
  Borland Pascal          GNU Pascal     bits(1)  signed

  ShortInt                ByteInt          8      yes
  Integer                 ShortInt        16      yes
  LongInt                 Integer         32      yes
  Comp                    LongInt, Comp   64      yes
  Byte                    Byte             8       no
  Word                    ShortWord       16       no
    -                     Word            32       no
    -                     LongWord        64       no
@end smallexample

(1) The size of the GNU Pascal types may depend on the platform. The sizes
above currently apply to most platforms, including the x86.

If you care for types with exactly the same size as in Borland Pascal,
take a look at the @samp{System} unit and read its comments.

You can also declare types with a specific size, and you can get the
size of a type with @samp{SizeOf} in bytes (like in Borland Pascal)
or @samp{BitSizeOf} in bits., e.g.

@smallexample
type
  MyInt  = Integer (42);  @{ 42 bits, signed @}
  MyWord = Word (2);      @{ 2 bits, unsigned, i.e. 0 .. 3 @}
  MyCard = Cardinal (2);  @{ the same @}

  HalfInt = Integer (BitSizeOf (Integer) div 2); @{ A signed integer type
    whose size is half as big as that of the normal Integer is regardless
    how big Integer will be on any platform the program is compiled on. @}
@end smallexample

@item
Borland's Real types are supported except for the 6-bytes software Real;
GNU's @samp{Real} has 8 bytes and is the same as @samp{Double}.
In addition there are alternative names for real types:

@smallexample
  Borland Pascal          GNU Pascal

  Single                  Single, ShortReal
  Real                      -
  Double                  Double, Real
  Extended                Extended, LongReal
  Comp                    Comp, LongInt
@end smallexample

@item
Complex numbers:  According to Extended Pascal, GNU Pascal has
built-in complex numbers.

@item
Record types: GNU Pascal by default alignes 32-bit fields on 4-byte
addresses because this improves performance.  The record
@smallexample
  Type
    myRec = record
      f, o, oo: Boolean;
      Bar: Integer;
    end (* myRec *);
@end smallexample
has 8 bytes, not 7.  Use the @code{--pack-struct} option or declare the
record as @samp{packed} to force GPC to pack it to 7 bytes;
see @ref{Code Gen Options}.

@item
In addition to Borland's procedural types, GNU Pascal has pointers to
procedures:

@smallexample
    Type
      FuncPtr = ^Function ( Real ): Real;
@end smallexample

Furthermore, GNU Pascal supports Standard Pascal's procedural
parameters---see below.
@end itemize

@c ----------------------------------------------------------------------------

@node Files
@section Files

@itemize @bullet
@item
Files like in Borland Pascal, including untyped files, @samp{BlockRead},
@samp{BlockWrite} and @samp{Assign} are supported by GPC. Instead of
@samp{Assign}, you can also use the ``Bind'' mechanism of Extended
Pascal.

@end itemize

@c ----------------------------------------------------------------------------

@node Built-in constants
@section Built-in constants

@itemize @bullet
@item
@samp{MaxInt}, @samp{MaxLongInt}, @samp{Pi} constants:  built-in.

@item
Other built-in constants:  GNU Pascal has @samp{MaxChar},
@samp{MaxReal}, and @samp{MinReal}.
@end itemize

@c ----------------------------------------------------------------------------

@node Built-in operators in BP and GPC
@section Built-in operators in BP and GPC

@itemize @bullet
@item
Exponentiation:  According to Extended Pascal, GNU Pascal
supports exponentiation operators @code{pow} and @code{**} which do not
exist in Borland Pascal.  You can use @code{x pow y} for integer
and @code{x ** y} for real or complex exponents; the basis may be
integer, real or complex in both cases.

@item
Address operator:  GNU Pascal accepts Borland's @code{@@}, but also
@code{&} as an address operator.

@item
GNU Pascal has a symmetric set difference operator @code{set1 >< set2}.
For more about this, see @ref{Extensions}.
@end itemize

@c ----------------------------------------------------------------------------

@node Built-in Procedures and Functions
@section Built-in Procedures and Functions

@itemize @bullet
@item
@samp{GetMem} and @samp{FreeMem}:  @samp{GetMem} can also act as a
function in GNU Pascal:

@smallexample
  p:= GetMem ( 1024 );
@end smallexample

The second parameter to @samp{FreeMem} is ignored by GNU Pascal and may
be omitted.  Memory blocks are always freed with the same size they were
allocated with.

Remark: Extended Pascal Schema types provide a cleaner approach
to most of the applications of @samp{GetMem} and @samp{FreeMem}.

@item
@samp{Min} and @samp{Max}:  GNU Pascal has built-in @samp{Min} and
@samp{Max} functions (two arguments) which work for all ordinal types
(@samp{Integer}, @samp{Char}, ...) plus @samp{Real}.

@item
@samp{UpCase}, @samp{High}, @samp{Low} functions:  built-in.

@item
@samp{Lo}, @samp{Hi}, @samp{Swap} functions:  not built-in, but available
in the @samp{System} unit.

@end itemize

@c ----------------------------------------------------------------------------

@node Parameters
@section Parameters

@itemize @bullet

@item
Untyped Var parameters can be denoted by

@cindex foo
@smallexample
  Procedure Foo ( Var x );
@end smallexample

@noindent like in Borland Pascal.  In GNU Pascal, you can also use

@smallexample
  Procedure Foo ( Var x: Void );
@end smallexample

@item
GNU Pascal defines ``ellipsis'' parameters for variable argument lists,

@smallexample
  Procedure Foo ( a: Integer; ... );
@end smallexample

@noindent but does not (yet) provide a portable mechanism to access the
additional arguments.

@item
Structured function return values:  According to Extended
Pascal, GNU Pascal allows structured function return values.

@item
Open array parameters
@smallexample
  Procedure Foo ( a: array of Integer );
@end smallexample
are implemented.  However, Standard Pascal conformant array parameters
(only partially implemented) are a ``cleaner'' mechanism to pass arrays
of variable size.

@item
GNU Pascal supports Standard Pascal's procedural parameters:

@smallexample
  Procedure DrawGraph ( Function f ( x: Real ): Real );
@end smallexample
@end itemize

@c ----------------------------------------------------------------------------

@node Miscellaneous
@section Miscellaneous

@itemize @bullet
@item
Headlines:  According to Extended Pascal, a Program headline
must contain the program's parameters:

@cindex foo
@smallexample
    Program Foo ( Input, Output );
@end smallexample

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

@item
Case statements:  In a case statement, GNU Pascal has
@code{otherwise} as an alternative to @code{else}
(according to Extended Pascal):

@smallexample
  case x of
    1: writeln ( 'one' );
    2: writeln ( 'two' );
    otherwise writeln ( 'many' );
  end (* case *);
@end smallexample

If there are two ore more statements following @code{otherwise},
they must be grouped with @code{begin} and @code{end}.

@item
Char constants: Character constants like @samp{^M} as well as @samp{#13}
are implemented into GNU Pascal.

@item
Sets: GNU Pascal has a @code{Card} function for sets
which counts their elements.

@item
Inline:  GNU Pasccal allows ``inline'' Procedures and Functions,
while Borland Pascal only allows machine code to be inlined:

Borland Pascal:

@smallexample
  Function Max ( x, y: Integer ): Integer;
  Inline ( $58 / $59 / $3B / $C1 / $7F / $01 / $91 );
@end smallexample

GNU Pascal:

@smallexample
  Inline Function Max ( x, y: Integer ): Integer;

  begin (* Max *)
    if x > y then
      Max:= x
    else
      Max:= y;
  end (* Max *);
@end smallexample

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

This feature is not so important as it might seem because in optimization
level 3 (see above), GNU Pascal automatically ``inlines'' short procedures
and functions.
@end itemize
