home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / fortran / 2792 < prev    next >
Encoding:
Internet Message Format  |  1992-07-21  |  1.4 KB

  1. Path: sparky!uunet!mcsun!sun4nl!cwi.nl!dik
  2. From: dik@cwi.nl (Dik T. Winter)
  3. Newsgroups: comp.lang.fortran
  4. Subject: Re: recursive I/O
  5. Message-ID: <6737@charon.cwi.nl>
  6. Date: 22 Jul 92 01:09:55 GMT
  7. References: <1992Jul21.223157.2775@ccu1.aukuni.ac.nz>
  8. Sender: news@cwi.nl
  9. Organization: CWI, Amsterdam
  10. Lines: 30
  11.  
  12. In article <1992Jul21.223157.2775@ccu1.aukuni.ac.nz> ecmtwhk@ccu1.aukuni.ac.nz (Thomas Koenig) writes:
  13.  > Is the following legal F77?  It works on the UNIX box I'm on at the
  14.  > moment, but I can imagine trouble with architectures which do not use
  15.  > a stack for argument passing, for example /370. 
  16.  > 
  17.  > C This assumes channels 6 and 0 are preconnected
  18.  >       PROGRAM MAIN
  19.  >       WRITE (6,*) FCN(2.3)
  20.  >       END
  21.  >       FUNCTION FCN(A)
  22.  >       IF (A.GT.2.) WRITE (0,*) 'Something horrible happened'
  23.  >       FCN = 2. - A
  24.  >       END
  25.  
  26. No, it is not legal.  I have seen things like this go wrong, also on
  27. machines where the stack *is* used for argument passing!  The assumption
  28. is that the write statement is compiled to a single call to the run-time
  29. system.  That is not necessarily true.  Consider a compilation of
  30.     WRITE (6, *) FCN(2.3)
  31. to (symbolical):
  32.     init_io(6)
  33.     init_format(*)
  34.     tmp = fcn(2.3)
  35.     write_real(tmp)
  36.     end_io()
  37. And, yes, there are compilers that do this.
  38. -- 
  39. dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland
  40. home: bovenover 215, 1025 jn  amsterdam, nederland
  41. dik@cwi.nl
  42.