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

  1. Path: sparky!uunet!mcsun!uknet!gdt!ccsdhd
  2. From: ccsdhd@gdt.bath.ac.uk (Dennis Davis)
  3. Newsgroups: comp.lang.fortran
  4. Subject: Re: recursive I/O
  5. Message-ID: <1992Jul22.112743.25481@gdt.bath.ac.uk>
  6. Date: 22 Jul 92 11:27:43 GMT
  7. References: <1992Jul21.223157.2775@ccu1.aukuni.ac.nz>
  8. Organization: Bath University Computing Services, UK
  9. Lines: 37
  10.  
  11. In article <1992Jul21.223157.2775@ccu1.aukuni.ac.nz> ecmtwhk@ccu1.aukuni.ac.nz (Thomas Koenig) writes:
  12. >Is the following legal F77?  It works on the UNIX box I'm on at the
  13. >moment, but I can imagine trouble with architectures which do not use
  14. >a stack for argument passing, for example /370. 
  15. >
  16. >C This assumes channels 6 and 0 are preconnected
  17. >      PROGRAM MAIN
  18. >      WRITE (6,*) FCN(2.3)
  19. >      END
  20. >      FUNCTION FCN(A)
  21. >      IF (A.GT.2.) WRITE (0,*) 'Something horrible happened'
  22. >      FCN = 2. - A
  23. >      END
  24.  
  25. This is illegal Fortran. See Section 12.11 of the Standard which
  26. states:
  27.  
  28.    "A function must not be referenced within an expression
  29.     appearing anywhere in an input/output statement if such a
  30.     reference causes an input/output statement to be executed."
  31.  
  32. I'd regard your program as illegal as it stands.  If the argument
  33. to the function were less than or equal to 2, I'd regard the
  34. program as legal.
  35.  
  36. Writing programs which can flip-flop in and out of legality is, in
  37. my opinion, a rather dubious practice.  Unfortunately they are all
  38. too easy to write.  For example the two lines of code:
  39.  
  40.       READ (5, *) I, J, K, L, M, N
  41.       A(I:J) = A(K:L) // A(M:N)
  42.  
  43. is legal or illegal depending upon the values of the integer
  44. variables read in.  See Section 10.4 of the Standard.
  45. -- 
  46. Dennis Davis, BUCS, University of Bath, Bath, BA2 7AY, United Kingdom
  47. D.H.Davis@bath.ac.uk     ...!uunet!mcsun!ukc!gdr!D.H.Davis
  48.