Extended Pascal

Dialect of programming language Pascal

A dialect of Pascal, as defined by standard ISO 10206 (1990).

Features not found in Standard Pascal:

  • added operators ** (exponentiation), >< (set symmetric difference) and => (rename identifiers at import/export).
  • added keywords AND_THEN, BINDABLE, EXPORT, IMPORT, MODULE, ONLY, OR_ELSE, OTHERWISE, POW, PROTECTED, QUALIFIED, RESTRICTED, VALUE (mostly related to modularity and short circuit boolean evaluation).
  • modularity and separate compilation. Each module exports an interface which makes entities of this module available from other modules.
  • schemata — collections of similar types.
  • new string processing capabilities.
  • variables binding.
  • direct access file processing, adding data to the end of the file.
  • constant expressions.
  • structured value constructors.
  • generalized function returns.
  • setting initial state for a variable enabled.
  • order of declarations relaxed (no forward references).
  • type inquiry: a variable/parameter can be declared having type of another variable/parameter.
  • constants maxchar, minreal, maxreal and epsreal allow to get details of implementation of char and real data types.
  • case statement improved: case-constant-list can contain ranges of values, and otherwise clause represents all values not listed before.
  • extension of set operations: symmetric difference, function to query number of elements in set and for-loop to iterate through the elements.
  • TimeStamp data type and related functions for time processing.
  • standard means of numeric input added.
  • representation of integer numbers using bases 2..36.
  • underscore (_) can be used in identifiers.
  • write can accept zero as field width parameters.
  • added halt procedure to stop program execution.
  • added complex numbers data type.
  • short circuit boolean evaluation.
  • protected parameters (can’t be modified within the procedure they are passed to).
  • exponentiation operation added.
  • conformant arrays.

Examples:

Quadratic equation:

Example for versions Free Pascal 2.0.4, Free Pascal 2.2.0, Turbo Pascal 1.0, Turbo Pascal 2.0, Turbo Pascal 3.0, Turbo Pascal 4.0, Turbo Pascal 5.0, Turbo Pascal 6.0, gpc 20070904

Pascal has built-in complex data type complex, but using it is inconvenient in this case, because writeln can’t output complex numbers directly, and functions Re and Im would have to be used. In this example calculations are done in real numbers. Library function halt (added in Extended Pascal) exits current block (in later versions it is replaced with exit).

program Quadratic;

var
   A,B,C,D: integer;

begin
   write('A = ');
   readln(A);
   if (A=0) then
   begin
      writeln('Not a quadratic equation.');
      halt;
   end;
   write('B = ');
   readln(B);
   write('C = ');
   readln(C);
   D := B*B-4*A*C;
   if (D=0) then
   begin
      writeln('x = ',-B/2.0/A);
      halt;
   end;
   if (D>0) then
   begin
      writeln('x1 = ',(-B+Sqrt(D))/2.0/A);
      writeln('x2 = ',(-B-Sqrt(D))/2.0/A);
   end
   else
   begin
      writeln('x1 = (',-B/2.0/A,',',Sqrt(-D)/2.0/A,')');
      writeln('x2 = (',-B/2.0/A,',',-Sqrt(-D)/2.0/A,')');
   end;
end.