@c Copyright (C) 1996-2002 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: 2002-05-10 (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 GNU family (@pxref{GNU}). 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, S390,
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://cygwin.com,CygWin} or
@uref{http://www.mingw.org,mingw},
@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://www.gnu.org/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}}
(@ref{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}@c
The compiler supports the following language standards
and quasi-standards:

@itemize @bullet
@item ISO-7185 Pascal (@pxref{Resources}),
@item most of ISO-10206 Extended Pascal,
@item Borland Pascal 7.0,
@item parts of Borland Delphi and Pascal-SC (PXSC).
@end itemize

@anch{pro}@c
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}@c
Conformant array parameters -- the standardized and comfortable way
to pass arrays of varying size to procedures and functions.
@examplehref{conformantdemo.pas}
@item
@anch{iteratordemo}@c
Passing local procedures as procedural parameters -- with full
access to all variables of the ``parent'' procedure.
@examplehref{iteratordemo.pas}
@item
@anch{filebuf1demo}@c
@anch{filebuf2demo}@c
Automatic 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}@c
True packed records and arrays. Pack 8 Booleans into 1 byte.
@examplehref{packdemo.pas}
@item
@anch{intfiledemo}@c
Internal files. You don't have to worry about creating temporary
file names and erasing the files later.
@examplehref{intfiledemo.pas}
@item
@anch{parserdemo}@c
Global @samp{goto}. (Yes, @samp{goto} has its place when it is not
restricted to the current routine.) @examplehref{parserdemo.pas}
@item
@anch{variantdemo}@c
Automatically set discriminants of variant records in @samp{New}.
@examplehref{variantdemo.pas}
@item
@anch{bigsetsdemo}@c
Sets of arbitrary size. @examplehref{bigsetsdemo.pas}
@end itemize

@item From Extended Pascal:

@itemize @minus
@item
@anch{stringschemademo}@c
Strings of arbitrary length. @examplehref{stringschemademo.pas}
@item
@anch{rwstringdemo}@c
@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}@c
System-independent date/time routines.
@examplehref{datetimedemo.pas}
@item
@anch{bigsetsdemo}@c
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}@c
@anch{parserdemo}@c
Complex numbers. @examplehref{mandelbrot.pas}
@examplehref{parserdemo.pas}
@item Exponentiation operators (@samp{pow} and @samp{**}) for real
and complex numbers.
@item
@anch{initvardemo}@c
Initialized variables. @examplehref{initvardemo.pas}
@item Functions can return array or record values.
@item
@anch{returnvardemo}@c
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}@c
Schemata -- the Pascal way to get dynamic arrays without dirty
tricks. @examplehref{schemademo.pas}
@item
@anch{dynamicarraydemo}@c
Local variables may have dynamic size.
@examplehref{dynamicarraydemo.pas}
@item
@anch{arrayslicedemo}@c
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}@c
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.png" width=133 height=138>
<br>
(PNG, 21 kB)
</a>
</td></tr></table>
@end html
@end ifset
@anch{crtdemo}@c
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).
@htmlbrclear
@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}@c
Supports BP style procedural variables as well as Standard Pascal's
procedural parameters. @examplehref{procvardemo.pas}
@item
@anch{portdemo}@c
A @samp{Ports} unit lets you access CPU I/O ports on systems where
this makes sense. @examplehref{portdemo.pas}
@item
@anch{bigmemdemo}@c
Special compatibility features to help migrating from BP to GPC,
like a @samp{GPC for BP} unit which provides some of GPC's features
for 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}
@item
@anch{binobjdemo}@c
Comes with a BP compatible @samp{binobj} utility.
@examplehref{binobjdemo.pas}
@end itemize

@item From Borland Delphi:

@itemize @minus
@item @samp{abstract} object types and methods
@item @samp{is} and @samp{as} operators to test object type
membership
@item Comments with @samp{//}
@item A @samp{SetLength} procedure for strings makes it unnecessary
to use dirty tricks like assignments to the ``zeroth character''.
@item @samp{Initialize} and @samp{Finalize} for low-level handling
of variables.
@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
@anch{c_gpc}@c
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}@c
@anch{gpc_c_unit}@c
or 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}@c
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}@c
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}@c
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}@c
Routines like @samp{FSplit} or @samp{FSearch} or @samp{FExpand} know
about the specifics of the various different operating systems.
@examplehref{fexpanddemo.pas}
@item
@anch{formattimedemo}@c
The @samp{FormatTime} function lets you format date and time values,
according to various formatting rules.
@examplehref{formattimedemo.pas}
@end itemize

@item Useful and portable GNU standard units:

@itemize @minus
@item
@anch{pipedemo}@c
@anch{demoproc}@c
A @samp{Pipe} unit gives you inter-process communication even under
plain DOS. @examplehref{pipedemo.pas}
@xexamplehref{demoproc.pas,Demo process for the example}
@item
@anch{regexdemo}@c
With the @samp{RegEx} unit you can do searches with @dfn{regular
expressions}. @examplehref{regexdemo.pas}
@item
@anch{factorial}@c
@anch{fibonacci}@c
@anch{power}@c
@anch{realpower}@c
@anch{pi}@c
The GNU MultiPrecision (@samp{GMP}) 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}@c
@anch{statfsdemo}@c
@anch{filelockdemo}@c
Posix functions 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}@c
A @samp{DosUnix} unit compensates for some of the incompatibilities
between two families of operating systems.
@examplehref{dosunixdemo.pas}
@item
@anch{md5demo}@c
An @samp{MD5} unit to compute MD5 message digests, according to RFC
1321. @examplehref{md5demo.pas}
@item
@anch{findfilesdemo}@c
A @samp{FileUtils} unit which provides some higher-level file and
directory handling routines. @examplehref{findfilesdemo.pas}
@item
@anch{stringhashdemo}@c
A @samp{StringUtils} unit which provides some higher-level string
handling routines. @examplehref{stringhashdemo.pas}
@item
@anch{gettextdemo}@c
@anch{localedemo}@c
An @samp{Intl} unit for internationalization.
@examplehref{gettextdemo.pas} @examplehref{localedemo.pas}
@item
@anch{trapdemo}@c
A @samp{Trap} unit to trap runtime errors and handle them within
your program. @examplehref{trapdemo.pas}
@item A @samp{HeapMon} unit to help you find memory leaks in your
programs.
@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}@c
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}.
