Conformant arrays and strong typing

  • Authors:
  • David V. Moffat

  • Affiliations:
  • -

  • Venue:
  • ACM '81 Proceedings of the ACM '81 conference
  • Year:
  • 1981

Quantified Score

Hi-index 0.00

Visualization

Abstract

Many persons have criticized—or defended— Pascal [1] for its lack of conformant arrays [2,3]. A conformant array is a formal parameter array whose bounds will conform to those of an actual parameter array. (The element types of both must be the same.) The lack of this feature is due to a desire for efficient compilation and execution. It is enforced by Pascal's convention that the index or bounds specification of an array is an integral part of the type of the array. For example, in: TYPE LIST&equil;ARRAY[1..10] OF REAL; LOST&equil;ARRAY[1..5] OF REAL; VAR LI: LIST; LO: LOST; LA: ARRAY[1. 10 ] OF REAL; FUNCTION SUM(A: LIST): REAL; it can be seen that the array bounds are nowhere specified in the parameter declaration; they are buried within the type definition. Thus, the call SUM(LI) is syntactically correct, but SUM(LO) is not, because the type of LO does not match the formal parameter. The call SUM(LA) is not correct, because LA has an anonymous (unnamed) type that matches (by convention) no other types. There is no way to generalize the SUM procedure to accept various arrays of reals.