home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!paladin.american.edu!gatech!news.ans.net!cmcl2!adm!news
- From: stone@hilbert.math.grin.edu (John David Stone)
- Newsgroups: comp.lang.pascal
- Subject: Pascal Standards Questions
- Message-ID: <35201@adm.brl.mil>
- Date: 24 Jan 93 22:17:01 GMT
- Sender: news@adm.brl.mil
- Lines: 47
-
-
- Max Ziff writes:
-
- > 1) The report specifies "conformant-array parameters". Are
- > these widely implemented? Is this part of any emerging specification?
- > What is the most portable, most polymorphic way of writing a function
- > that, say, takes the average of the elements of an array which it is
- > passed as a parameter?
-
- Conformant array parameters are part of the ISO "level 1" standard;
- in fact, they are (I believe) the _only_ difference between the ISO "level
- 1" and the ISO "level 0" standard. They are widely implemented. (For
- example, of the Pascal compilers used extensively at Grinnell, both the Sun
- Pascal compiler and the Oregon Software Pascal-2 compiler for VMS provide
- them.)
-
- Here's how you use them to write the function Ziff asks about:
-
- function average (var arr: array [low .. high: integer] of real): real;
- var
- index: integer;
- sum: real;
- begin
- sum := 0.0;
- for index := low to high do
- sum := sum + arr[index];
- average := sum / (high - low + 1)
- end;
-
- The polymorphism is, of course, _very_ limited; the only
- flexibility is in the bounds of the index type of the array.
-
- > 2) Is there any standard for signalling errors? Is there
- > a portable way of signalling the same error that is generated at
- > run-time by divide-by-zero? Are run-time errors part of any standard?
-
- No.
-
- > 3) Is there a portable, standard way of generating a value
- > NaN?
-
- No.
-
- ------ John David Stone - Lecturer in Computer Science and Philosophy -----
- -------------- Manager of the Mathematics Local-Area Network --------------
- -------------- Grinnell College - Grinnell, Iowa 50112 - USA --------------
- -------- stone@math.grin.edu - (515) 269-3181 - stone@grin1.bitnet --------
-