@c Copyright (C) 1996-2000 Free Software Foundation, Inc.
@c For copying conditions, see the file gpc.texi.
@c This file is part of the GPC Manual.
@c
@c Authors: Peter Gerwinski <peter@gerwinski.de>
@c          Frank Heckenbach <frank@pascal.gnu.de>
@c
@c Last modification: 27 Aug 2000 (file up to date)

@include macros.texi

@node Highlights
@chapter Some of GPC's most interesting features.
@cindex highlights

The GNU Pascal Compiler (GPC) is, as the name says, the Pascal
compiler of the @localuref{gnu.html,GNU} family. This means:

@itemize @bullet

@item GPC is a 32/64 bit compiler,

@item does not have limits like the 64 kB or 640 kB limit known from
certain operating systems -- even on those systems --,

@item runs on all operating systems supported by GNU C, including

@itemize @minus
@item @uref{http://www.linux.org,Linux} on Intel, Alpha, and all
other supported types of hardware,
@item the BSD family: @uref{http://www.freebsd.org,FreeBSD},
@uref{http://www.netbsd.org,NetBSD},
@uref{http://www.openbsd.org,OpenBSD},
@item DOS with 32 bits, using
@uref{http://www.delorie.com/djgpp/,DJGPP} or
@uref{http://www.leo.org/pub/comp/os/os2/leo/gnu/emx+gcc/index.html,EMX},
@item MS-Windows 9x/NT, using
@uref{http://sourceware.cygnus.com/cygwin/,CygWin} or
@uref{http://agnes.dida.physik.uni-essen.de/~janjaap/mingw32/,mingw32},
@item OS/2 with
@iftex
@*
@end iftex
@uref{http://www.leo.org/pub/comp/os/os2/leo/gnu/emx+gcc/index.html,EMX},
@item MIPS-SGI-IRIX,
@item Alpha-DEC-OSF,
@item Sparc-Sun-Solaris,
@item HP/UX
@end itemize
@noindent and more,

@item can act as a native or as a cross compiler between all
supported systems,

@item produces highly optimized code for all these systems,

@item is
@uref{http://home.pages.de/~GNU/philosophy/free-sw.html,Free Software}
(@uref{http://www.opensource.org,Open-Source Software})
according to the
@uref{http://www.gnu.org/copyleft/gpl.html,@strong{GNU General Public License}}
(see also @localuref{gnu.html,GNU} for remarks and translations),

@item is compatible to other GNU languages and tools such as GNU C
and the GNU debugger.
@end itemize

@anch{lang,The compiler supports the following language standards and quasi-standards:}

@itemize @bullet
@item @localuref{misc.html#ISO,ISO-7185 Standard Pascal},
@item most of @localuref{misc.html#ISO,ISO-10206 Extended Pascal},
@item Borland Pascal 7.0,
@item parts of Pascal-SC (PXSC).
@end itemize

@anch{pro,Some highlights:}

@c DEMO-START

@itemize @bullet

@item From Standard Pascal: Many popular Pascal compilers claim to
extend Standard Pascal but miss these important features.

@itemize @minus
@item
@anch{conformantdemo,Conformant array parameters} -- the
standardized and comfortable way to pass arrays of varying size to
procedures and functions. @examplehref{conformantdemo.pas}
@item
@anch{iteratordemo,Passing local procedures} as procedural
parameters -- with full access to all variables of the ``parent''
procedure. @examplehref{iteratordemo.pas}
@item
@anch{filebuf1demo,Automatic}
@anch{filebuf2demo,file}
buffers and standard @samp{Get} and @samp{Put} procedures. Read
ahead from files without temporary variables.
@examplehref{filebuf1demo.pas} This allows you, for instance, to
validate numeric input from text files before reading without
conversion through strings. @examplehref{filebuf2demo.pas}
@item
@anch{packdemo,True packed records and arrays.} Pack 8
Booleans into 1 byte. @examplehref{packdemo.pas}
@item
@anch{intfiledemo,Internal files.} You don't have to worry
about creating temporary file names and erasing the files later.
@examplehref{intfiledemo.pas}
@item
@anch{parserdemo,Global @samp{goto}.} (Yes, @samp{goto} has
its place when it is not restricted to stay in the current routine.)
@examplehref{parserdemo.pas}
@item
@anch{variantdemo,Automatically set discriminants} of
variant records in @samp{New}. @examplehref{variantdemo.pas}
@item
@anch{bigsetsdemo,Sets of arbitrary size.}
@examplehref{bigsetsdemo.pas}
@end itemize

@item From Extended Pascal:

@itemize @minus
@item
@anch{stringschemademo,Strings of arbitrary length.}
@examplehref{stringschemademo.pas}
@item
@anch{rwstringdemo,@samp{ReadStr} and @samp{WriteStr}.}
Read from and write to strings with the full comfort of
@samp{ReadLn}/@samp{WriteLn}. @examplehref{rwstringdemo.pas}
@item
@anch{datetimedemo,System-independent date/time routines.}
@examplehref{datetimedemo.pas}
@item
@anch{bigsetsdemo,Set member iteration:}
@samp{@w{for Ch in ['A' .. 'Z', 'a' .. 'z'] do @dots{}}}
@examplehref{bigsetsdemo.pas}
@item Set extensions (symmetric difference, @samp{Card})
@item Generalized @samp{Succ} and @samp{Pred} functions
(@code{@w{foo := Succ (bar, 5);}}).
@item
@anch{mandelbrot,Complex}
@anch{parserdemo,numbers.}
@examplehref{mandelbrot.pas} @examplehref{parserdemo.pas}
@item Exponentiation operators (@samp{pow} and @samp{**}) for real
and complex numbers.
@item
@anch{initvardemo,Initialized variables.}
@examplehref{initvardemo.pas}
@item Functions can return array or record values.
@item
@anch{returnvardemo,Return value variables.}
@examplehref{returnvardemo.pas}
@item Modules.
@item Non-decimal numbers in base 2 through 36: @samp{base#number}.
@item @samp{MinReal}, @samp{MaxReal}, @samp{EpsReal}, @samp{MaxChar}
constants.
@item
@anch{schemademo,Schemata} -- the Pascal way to get dynamic
arrays without dirty tricks. @examplehref{schemademo.pas}
@item
@anch{dynamicarraydemo,Local variables} may have dynamic size.
@examplehref{dynamicarraydemo.pas}
@item
@anch{arrayslicedemo,Array Slice Acces} -- access parts of
an array as a smaller array, even on the left side of an assignment
@examplehref{arrayslicedemo.pas}
@end itemize

@item Compatible to Borland Pascal 7.0 with objects (BP):

@itemize @minus
@item
@anch{absdemo,Supports units}, objects, @dots{}, and makes
even things like @samp{absolute} variables portable.
@examplehref{absdemo.pas}
@item Comes with portable versions of the BP standard units with
full source.
@item
@ifset html
@html
<table align=right><tr><td>
<a href="crtdemo.png">
<img alt="[CRTDemo screen]" src="crtdemo-small.jpg" width=133 height=138>
<br>
(PNG, 21 kB)
</a>
</td></tr></table>
@end html
@end ifset
@anch{crtdemo,True} network-transparent CRT unit: You can run your
CRT applications locally or while being logged in remotely, without
any need to worry about different terminal types. Compatible to BP's
unit, but with many extensions, such as overlapping windows.
@examplehref{crtdemo.pas}
@item
Fully functional GUI (X11) version of CRT (also completely
network transparent).
@ifset html
@html
<br clear="all">
@end html
@end ifset
@item The @samp{Random} function can produce the same sequence of
pseudo-random numbers as BP does -- if you need that instead of the
much more elaborate default algorithm.
@item
@anch{procvardemo,Supports BP style procedural variables} as well as
Standard Pascal's procedural parameters.
@examplehref{procvardemo.pas}
@item
@anch{portdemo,A @samp{Ports} unit} lets you access CPU I/O
ports on systems where this makes sense. @examplehref{portdemo.pas}
@item
@anch{bigmemdemo,Special} compatibility features to help migrating
from BP to GPC, like a @samp{GPC for BP} unit which provides some of
GPC's features under BP, and some routines to access sets of large
memory blocks in a uniform way under GPC and BP (even in real mode).
@examplehref{bigmemdemo.pas}
@end itemize

@item From Pascal-SC (PXSC):

@itemize @minus
@item User-definable operators. Add your vectors with @samp{+}.
@end itemize

@item Carefully designed GNU extensions help you to make your
real-world programs portable:

@itemize @minus
@item 64-bit signed and unsigned integer types.
@item A Delphi-compatible @samp{SetLength} procedure for strings
makes it unnecessary to use dirty tricks like assignments to the
``zeroth character''.
@item
@anch{c_gpc,Special types} guarantee compatibility to other GNU
languages such as GNU C. Directives like @samp{@w{@{$L foo.c@}}}
make it easy to maintain projects written in multiple languages,
e.g., including code written in other languages into Pascal programs
@xexamplehref{c_gpc.pas,Example (Pascal part)}
@xexamplehref{c_gpc_c.c,Example (C part)},
@item
@anch{gpc_c_pas,or}
@anch{gpc_c_unit,including}
Pascal code into programs written in other languages.
@xexamplehref{gpc_c_pas.pas,Example (Pascal part)}
@xexamplehref{gpc_c_unit.pas,Example (Pascal unit)}
@xexamplehref{gpc_c_c.c,Example (C part)}
@item
@anch{endiandemo,Extensions} like @samp{BitSizeOf} and
@samp{ConvertFromBigEndian} help you to deal with different data
sizes and endianesses. @examplehref{endiandemo.pas}
@item Little somethings like @samp{DirSeparator},
@samp{PathSeparator}, @samp{GetTempDirectory} help you to write
programs that look and feel ``at home'' on all operating systems.
@item
@anch{pexecutedemo,The @samp{PExecute} routine} lets you
execute child processes in a portable way that takes full advantage
of multitasking environments. @examplehref{pexecutedemo.pas}
@item
@anch{getoptdemo,The GNU GetOpt routines} give you
comfortable access to Unix-style short and long command-line options
with and without arguments. @examplehref{getoptdemo.pas}
@item
@anch{fexpanddemo,Routines} like @samp{FSplit} or @samp{FSearch} or
@samp{FExpand} know about the specifics of the various different
operating systems. @examplehref{fexpanddemo.pas}
@end itemize

@item Useful and portable GNU standard units:

@itemize @minus
@item
@anch{pipedemo,A @samp{Pipe} unit}
@anch{demoproc,gives} you inter-process
communication even under plain DOS. @examplehref{pipedemo.pas}
@xexamplehref{demoproc.pas,Demo process for the example}
@item
@anch{regexdemo,With the GNU RegEx unit} you can do searches
with @dfn{regular expressions}. @examplehref{regexdemo.pas}
@item
@anch{factorial,The}
@anch{fibonacci,GNU}
@anch{power,MultiPrecision}
@anch{realpower,(GMP)}
@anch{pi,unit}
allows you to do arithmetics with integer, real, and rational
numbers of arbitrary precision.
@xexamplehref{factorial.pas,Example: factorial}
@xexamplehref{fibonacci.pas,Example: fibonacci}
@xexamplehref{power.pas,Example: power}
@xexamplehref{realpower.pas,Example: real power}
@xexamplehref{pi.pas,Example: pi}
@item
@anch{readdirdemo,Posix}
@anch{statfsdemo,functions}
@anch{filelockdemo,like}
@samp{ReadDir}, @samp{StatFS} or @samp{FileLock} provide an
efficient, easy-to-use and portable interface to the operating
system. @examplehref{readdirdemo.pas} @examplehref{statfsdemo.pas}
@examplehref{filelockdemo.pas}
@item
@anch{dosunixdemo,A @samp{DosUnix} unit} compensates for
some of the incompatibilities between two families of operating
systems. @examplehref{dosunixdemo.pas}
@item
@anch{md5demo,An @samp{MD5} unit} to compute MD5 message digests,
according to RFC 1321. @examplehref{md5demo.pas}
@item
@anch{findfilesdemo,A @samp{FileUtils} unit} which provides some
higher-level file and directory handling routines.
@examplehref{findfilesdemo.pas}
@item
@anch{stringhashdemo,A @samp{StringUtils} unit} which provides some
higher-level file and directory handling routines.
@examplehref{stringhashdemo.pas}
@item
@anch{trapdemo,A @samp{Trap} unit} to trap runtime errors and handle
them within your program. @examplehref{trapdemo.pas}
@end itemize
@end itemize

The demo programs mentioned above are available both on the WWW and
in GPC source and binary distributions.

@c DEMO-END

@anch{contra,Disadvantages:}

@itemize @bullet

@item The GNU debugger (GDB) does not yet understand Pascal syntax
and types; you have to use C syntax when debugging Pascal programs
with GDB.

@item With GPC you get longer compilation times than with, e.g.,
Borland Pascal.
@end itemize

@strong{Co-workers welcome!}

Able, committed programmers are always welcome in the GNU Pascal
team. If you want to be independent of companies that you must pay
for getting a compiler with more restrictive licensing conditions
that only runs on @emph{one} operating system, be invited to join
the development team, @ref{Contributors}.
