home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sun4nl!cwi.nl!dik
- From: dik@cwi.nl (Dik T. Winter)
- Newsgroups: comp.lang.fortran
- Subject: Re: recursive I/O
- Message-ID: <6737@charon.cwi.nl>
- Date: 22 Jul 92 01:09:55 GMT
- References: <1992Jul21.223157.2775@ccu1.aukuni.ac.nz>
- Sender: news@cwi.nl
- Organization: CWI, Amsterdam
- Lines: 30
-
- In article <1992Jul21.223157.2775@ccu1.aukuni.ac.nz> ecmtwhk@ccu1.aukuni.ac.nz (Thomas Koenig) writes:
- > Is the following legal F77? It works on the UNIX box I'm on at the
- > moment, but I can imagine trouble with architectures which do not use
- > a stack for argument passing, for example /370.
- >
- > C This assumes channels 6 and 0 are preconnected
- > PROGRAM MAIN
- > WRITE (6,*) FCN(2.3)
- > END
- > FUNCTION FCN(A)
- > IF (A.GT.2.) WRITE (0,*) 'Something horrible happened'
- > FCN = 2. - A
- > END
-
- No, it is not legal. I have seen things like this go wrong, also on
- machines where the stack *is* used for argument passing! The assumption
- is that the write statement is compiled to a single call to the run-time
- system. That is not necessarily true. Consider a compilation of
- WRITE (6, *) FCN(2.3)
- to (symbolical):
- init_io(6)
- init_format(*)
- tmp = fcn(2.3)
- write_real(tmp)
- end_io()
- And, yes, there are compilers that do this.
- --
- dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland
- home: bovenover 215, 1025 jn amsterdam, nederland
- dik@cwi.nl
-