home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / pascal / 8497 < prev    next >
Encoding:
Internet Message Format  |  1993-01-24  |  2.1 KB

  1. Path: sparky!uunet!paladin.american.edu!gatech!news.ans.net!cmcl2!adm!news
  2. From: stone@hilbert.math.grin.edu (John David Stone)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Pascal Standards Questions
  5. Message-ID: <35201@adm.brl.mil>
  6. Date: 24 Jan 93 22:17:01 GMT
  7. Sender: news@adm.brl.mil
  8. Lines: 47
  9.  
  10.  
  11.         Max Ziff writes:
  12.  
  13. >           1) The report specifies "conformant-array parameters".  Are
  14. >  these widely implemented?  Is this part of any emerging specification?
  15. >  What is the most portable, most polymorphic way of writing a function
  16. >  that, say, takes the average of the elements of an array which it is
  17. >  passed as a parameter?
  18.  
  19.         Conformant array parameters are part of the ISO "level 1" standard;
  20. in fact, they are (I believe) the _only_ difference between the ISO "level
  21. 1" and the ISO "level 0" standard.  They are widely implemented.  (For
  22. example, of the Pascal compilers used extensively at Grinnell, both the Sun
  23. Pascal compiler and the Oregon Software Pascal-2 compiler for VMS provide
  24. them.)
  25.  
  26.         Here's how you use them to write the function Ziff asks about:
  27.  
  28.     function average (var arr: array [low .. high: integer] of real): real;
  29.     var
  30.         index: integer;
  31.         sum: real;
  32.     begin
  33.         sum := 0.0;
  34.         for index := low to high do
  35.             sum := sum + arr[index];
  36.         average := sum / (high - low + 1)
  37.     end;
  38.  
  39.         The polymorphism is, of course, _very_ limited; the only
  40. flexibility is in the bounds of the index type of the array.
  41.  
  42. >           2) Is there any standard for signalling errors?  Is there
  43. >  a portable way of signalling the same error that is generated at
  44. >  run-time by divide-by-zero?  Are run-time errors part of any standard?
  45.  
  46.         No.
  47.  
  48. >           3) Is there a portable, standard way of generating a value
  49. >  NaN?
  50.  
  51.         No.
  52.  
  53. ------  John David Stone - Lecturer in Computer Science and Philosophy  -----
  54. --------------  Manager of the Mathematics Local-Area Network  --------------
  55. --------------  Grinnell College - Grinnell, Iowa 50112 - USA  --------------
  56. --------  stone@math.grin.edu - (515) 269-3181 - stone@grin1.bitnet  --------
  57.