Path: utzoo!mnetor!uunet!mcvax!botter!klipper!victor From: victor@cs.vu.nl (L. Victor Allis) Newsgroups: comp.lang.pascal Subject: Re: Conformable Arrays Message-ID: <964@klipper.cs.vu.nl> Date: 21 Dec 87 00:12:07 GMT References: <1472@cartan.Berkeley.EDU> Reply-To: victor@cs.vu.nl (Victor Allis) Organization: VU Informatica, Amsterdam Lines: 44 In article <1472@cartan.Berkeley.EDU> naparst@cartan.Berkeley.EDU (Harold Naparst) writes: >I don't quite understand conformable array parameters. > > 1) How do you pass part of an array, like in fortran ? > 2) Probably most importantly, are conformable arrays standard ? Cooper > says something about Level 1 and Level 2 Pascal. What finally happened ? 1) It is not possible to pass parts of array's in Pascal, not even using conformant array paramaters. In Pascal one has to specify exactly on what type of parameter the function or procedure is going to work. Sometimes you want to perform the same operations on similar, but different typed variables. Suppose you use at least two different real array's. You want to know the average of the elements in the array's. It would be boring to write two similar functions to perform this actions. This is the place where conformant array parameters come in: function Average(SomeArray : array[Lower..Upper: integer] of real): real; var i : integer; Sum : real; begin Sum := 0.0; for i := Lower to Upper do Sum := Sum + SomeArray[i]; Average := Sum / (Upper - Lower + 1) end; This function can be called with each actual parameter which is a real arry, with index a subrange of integer, instead of only one type of array. This is the only place in Pascal where structure-equivalence is important instead of name-equivalence. 2) In fact it is called level 0 Pascal (no conformant array parameters) and level 1 Pascal (with conformant array parameters). Both levels are defined in the Pascal ISO-standard. I can recommend the Pascal User Manual and Report by Jensen and Wirth. This book will answer all your questions. Victor Allis. Vrije Universiteit of Amsterdam. The Netherlands.