[comp.lang.pascal] languages for number crunching

mccalpin@vax1.acs.udel.EDU (John D Mccalpin) (03/14/90)

In article <18101@duke.cs.duke.edu>, hsg@romeo.cs.duke.edu (Henry Greenside) writes:
>It continues to be frustrating that the ANSI C committees do not listen
>to the needs of scientists: no complex, no power notation (**), no
>conformant arrays.

In article <780@s5.Morgan.COM> amull@Morgan.COM (Andrew P. Mullhaupt) writes:
>Try the dPANS for Extended Pascal on for size. The new language
>has variable size arrays, complex numbers, and separate compilation.
	[...]
>2. Is there some good reason why people are not more interested
>in this language in the US? A good Extended Pascal compiler for
>UNIX would be just the thing.

Well if my experience is typical, then the reason that there is not
more interest in the US is that lots of us have *never heard of it*!

Where does one get information on such critters?  
	Documentation?
	Reviews?
	Comparisons with Pascal/Modula-2/Modula-3?

>The GNU pascal project had adopted this standard for it's language, but
>that project got stalled a little while ago.

Did it get stalled for technical details or lack of resources?
Who has been working on this?

>If anybody's got news of a UNIX compiler for Extended Pascal let me know.
>Andrew Mullhaupt

And please post the info to the net!
Perhaps it is not too late for Pascal to make a comeback in the
scientific computing fields....
-- 
John D. McCalpin - mccalpin@vax1.acs.udel.edu
		   mccalpin@delocn.udel.edu
		   mccalpin@scri1.scri.fsu.edu

reagan@hiyall.enet.dec.com (John R. Reagan) (03/14/90)

There has been a request for a summary of the new Extended Pascal
standard recently completed by the Pascal committee.

Here is a list of the new features with some examples.  As a disclaimer,
I may have left out a few things or gotten a few wrong.

Before the list of features, I'll talk about availability...  To the
best of my knowledge, there is no complete implementation of Extended
Pascal yet (as of 13-Mar-1990).  However, this is not surprising since
it only was approved by the IEEE in December of 1989 and X3 in February
of 1990.  The standard is due to be published by the IEEE sometime
soon.

However, there are several vendors that have announced plans to add
features from Extended Pascal.  I won't speak for them....  The one
I *can* speak of is VAX Pascal.  VAX Pascal V4.0 was just released
by Digital.  It contains many, but not all, of the new features from 
Extended Pascal and many of VAX Pascal's extensions are now standard 
features in Extended Pascal. 

There are some popular features (namely object oriented support
and exception handling) that are missing from the Extended Pascal
standard.  The committee is aware of the need for these features,
but didn't get them finished for the standard.  The committee expects
to release technical reports in the coming year on both of these
areas.

Enjoy!

			-John Reagan, VAX Pascal Project Leader &
				      X3J9 Secretary


Features of Extended Pascal (from the foreword of the standard):

- Modularity and Separate Compilation.  Modularity provides for
  separately-compilable program components, while maintaining type
  security.

  o Each module exports one or more interfaces containing entities
    (values, types, schemata, variables, procedures, and functions)
    from that module, thereby controlling visibility into the module.

  o A variable may be protected on export, so that an importer may use
    it but not alter its value.  A type may be restricted, so that its
    structure is not visible.

  o The form of a module clearly separates its interfaces from its
    internal details.

  o Any block may import one or more interfaces.  Each interface may
    be used in whole or in part.

  o Entities may be accessed with or without interface-name qualification.

  o Entities may be renamed on export or import.

  o Initialization and finalization actions may be specified for each
    module.

  o Modules provide a framework for implementation of libraries and
    non-Pascal program components.

Example:

module employee_sort interface;

   export employee_sort = (sort_by_name,sort_by_clock_number,employee_list);

   import generic_sort;

   type
      employee = record
         last_name,first_name : string(30);
         clock_number : 1..maxint;
      end;

      employee_list(num_employees : max_sort_index) =
         array [1..num_employees] of employee;

   procedure sort_by_name(employees : employee_list;
                 var something_done : Boolean);

   procedure sort_by_clock_number(employees : employee_list;
                 var something_done : Boolean);

end.


- Schemata. A schema determines a collection of similar types.  Types
  may be selected statically or dynamically from schemata.

  o Statically selected types are uses as any other types are used.

  o Dynamically selected types subsume all the functionality of,
    and provide functional capability beyond, conformant arrays.

  o The allocation procedure NEW may dynamically select the type
    (and thus the size) of the allocated variable.

  o A schematic formal-parameter adjusts to the bounds of its
    actual-parameters.

  o The declaration of a local variable may dynamically select the
    type (and thus the size) of the variable.

  o The with-statement is extended to work with schemata.

  o Formal schema discriminants can be used as variant selectors.

Example:

type
   SWidth = 0..1023;
   SHeight = 0..2047;
   Screen(width: SWidth; height: SHeight) =
            array [0..height, 0..width] of boolean;

   Matrix(M,N: integer) = array [1..M,1..N] of real;

   Vector(M: integer) = array [1..M] of real;

   Color = (red,yellow);
   Color_Map(formal_discriminant: color) = 
      record
      case formal_discriminant of
      red: (red_field : integer);
      yellow : (yellow_field : integer);
      end;

function bound : integer;
 var s : integer;
   begin
   write('How big?');
   readln(s);
   bound := s;
   end;

var
   My_Matrix : Matrix(10,10);
   My_Vector : Vector(bound);  { Notice the run-time expression! }
   Matrix_Ptr : ^Matrix;
   X,Y : integer;

   begin
   readln(x,y);
   new(Matrix_Ptr,X,Y);
   end


- String Capabilities.  The comprehensive string facilities unify fixed-length
  strings and character values with variable-length strings.

  o All string and character values are compatible.

  o The concatenation operator (+) combines all string and character values.

  o String may be compared using blank padding via the relation operators,
    or using no padding via the functions EQ, LT, GT, NE, LE, and GE.

  o The functions LENGTH, INDEX, SUBSTR, and TRIM provide information
    about, or manipulate, strings.

  o The substring-variable notation makes accessible, as a variable, a
    fixed-length portion of a string variable.

  o The transfer procedures READSTR and WRITESTR process strings in the same
    manner that READ and WRITE process textfiles.

  o The procedure READ has been extended to read strings from textfiles.


- Binding of Variables.

  o A variable may optionally be declared to be bindable.  Bindable
    variables may be bound to external entities (file storage,
    real-time clock, command lines, etc.).  Only bindable variables
    may be so bound.

  o The procedures BIND and UNBIND, together with the related type
    BINDINGTYPE, provide capabilities for connection and disconnection
    of bindable internal (file and non-file) variables to external
    entities.

  o The function BINDING returns current or default binding information.


- Direct Access File Handling.

  o The declaration of a direct-access file indicates an index by which
    individual file elements may be accessed.

  o The procedures SEEKREAD, SEEKWRITE, and SEEKUPDATE position the file.

  o The functions POSITION, LASTPOSITION, and EMPTY report the current
    position and size of the file.

  o The update file mode and its associated procedure UPDATE provide
    in-place modification.


- File Extend Procedure.  The procedure EXTEND prepares an existing
  file for writing at its end.


- Constant Expressions.  A constant expression may occur in any context
  needing a constant value.


- Structured Value Constructors.  An expression may represent the value
  of an array, record, or set in terms of its components.  This is
  particularly value for defining structured constants.


- Generalized Function Results.  The result of a function may have any
  assignable type.  A function result variable may be specified, which
  is especially useful for functions returning structures.  [A function
  call may be directly array-index, field-selected, or pointer-dereferenced
  without having to use an intermediate variable.]


- Initial Variable State.  The initial state specifier of a type [or record
  field] can specify the value that variables [, or fields, or variant
  selectors] are to be created with.


- Relaxation of Ordering of Declarations.  There may be any number of
  declaration parts (labels, constants, types, variables, procedures
  and functions) and in any order.  The prohibition of forward references
  in declarations is retained.


- Type Inquiry.  A variable or parameter may be declared to have the
  type of another parameter of another variable.


- Implementation Characteristics.  The constant MAXCHAR is the largest
  value of type CHAR.  The constant MINREAL, MAXREAL, and EPSREAL describe
  the range of magnitude and the precision of real arithmetic.


- Case-Statement and Variant Record Enhancements.  Each case-constant-list
  may contain ranges of values.  An OTHERWISE clause represents all
  values not listed in the case-constant-lists.


- Set Extensions.

  o An operator (><) computes the set symmetric difference.

  o The function CARD yields the number of members in a set.

  o A form of the for-statement iterates through the members of a set.


- Date and Time.  The procedure GETTIMESTAMP and the functions DATE and
  TIME, together with the related type TIMESTAMP, provide numeric
  representations of the current date and time and convert numeric
  representations to strings.


- Inverse Ord.  A generalizations of SUCC and PRED provides an inverse
  ORD capability.


- Standard Numeric Input.  The definition of acceptable character
  sequences read from a textfile includes all standard numeric
  representations defined by ANSI X3.42-1975.


- Non-Decimal Representation of Numbers.  Integer numeric constants may
  be expressed using bases two through thirty-six.


- Underscores in Identifiers.  The underscore character (_) may occur
  within identifiers and are significant to their spelling.


- Zero Field Widths.  The total field width and fraction digits expressions
  in write parameters may be zero.


- Halt.  The procedure HALT causes termination of the program.

- Complex Numbers.

  o The simple-type COMPLEX allows complex numbers to be expressed in
    either Cartesian or polar notation.

  o The monadic operators + and - and dyadic operators +, -, *, /,
    =, [and] <> operate on complex values.

  o The functions CMPLX, POLAR, RE, IM, and ARG construct or provide
    information about complex values.

  o The functions ABS, SQR, SQRT, EXP, LN, SIN, COS, [and] ARCTAN
    operate on complex values.


- Short Circuit Boolean Evaluation.  The operators AND_THEN and OR_ELSE
  are logically equivalent to AND and OR, except that evaluation order
  is defined as left-to-right, and the right operand is not evaluated
  if the value of the expression can be determined solely from the value
  of the left operand.


- Protected Parameters.  A parameter of a procedure or a function can
  be protected from modification within the procedure or function.


- Exponentation.  The operators ** and POW provide exponentation of
  integer, real, and complex numbers to real and integer powers.


- Subranges Bounds.  A general expression can be used to specify the
  value of either bound in a subrange.


- Tag Fields of Dynamic Variables.  Any tag field specified by a
  parameter to the procedure NEW is given the specified value.


- Conformant Arrays.  Conformant arrays provide upward compatibility
  with level 1 of ISO 7185, Programming languages - PASCAL.

---
John Reagan
Digital Equipment Corporation
reagan@hiyall.dec.com
---