Function: _header_programming/control
Class: header
Section: programming/control
Doc:
 \section{Programming in GP: control statements}
 \sidx{programming}\label{se:programming}

   A number of control statements are available in GP. They are simpler and
 have a syntax slightly different from their C counterparts, but are quite
 powerful enough to write any kind of program. Some of them are specific to
 GP, since they are made for number theorists. As usual, $X$ will denote any
 simple variable name, and \var{seq} will always denote a sequence of
 expressions, including the empty sequence.

 \misctitle{Caveat} In constructs like
 \bprog
     for (X = a,b, seq)
 @eprog\noindent
 the variable \kbd{X} is lexically scoped to the loop, leading to possibly
 unexpected behavior:
 \bprog
     n = 5;
     for (n = 1, 10,
       if (something_nice(), break);
     );
     \\ @com at this point \kbd{n} is 5 !
 @eprog\noindent
 If the sequence \kbd{seq} modifies the loop index, then the loop
 is modified accordingly:
 \bprog
     ? for (n = 1, 10, n += 2; print(n))
     3
     6
     9
     12
 @eprog

Function: _header_programming/specific
Class: header
Section: programming/specific
Doc:
 \section{Programming in GP: other specific functions}
 \label{se:gp_program}

 In addition to PARI mathematical functions and GP control statements, we
 now describe general purpose routines built into the interpreter. They allow
 input/output and manipulating data structures (character strings,
 lists, maps) but also calling an exernal program, starting timers or getting
 information about \kbd{gp}'s state. The powerful \kbd{install} function
 allows to import any public PARI function in the GP language (as well as
 functions provided by external libaries).

 Many of these functions expect character strings as arguments.
 We recall the difference between \emph{strings} and \emph{keywords} contexts
 (see \secref{se:strings}). Keywords are taken verbtim and you can type
 them without any enclosing quotes. Strings are dynamic objects, where
 everything outside quotes gets expanded. For instance, in keyword context,
 \kbd{1 + 1} is just \kbd{"1 + 1"}; whereas in string context it becomes
 \kbd{"2"}.

Function: _header_programming/parallel
Class: header
Section: programming/parallel
Doc:
 \section{Parallel programming in GP}

 These function are only available if PARI was configured using
 \kbd{Configure --mt=\dots}. Two multithread interfaces are supported:

 \item POSIX threads

 \item Message passing interface (MPI)

 As a rule, POSIX threads are well-suited for single systems, while MPI is used
 by most clusters. However the parallel GP interface does not depend on the
 chosen multithread interface: a properly written GP program will work
 identically with both.
