J3/04-105 Date: 7 Dec 03 To: J3 From: Dan Nagle Subject: DEFER= specifier on CLOSE Named scratch files would have provided some functionality if a way could have been found to avoid the unsatisfactory lack of a way to specify the desired interaction between the name specified and existing names in the file syatem. Adding a defer= specifier to close gives a superset of the functionality of named scratch files. Number: Title: DEFER= on the CLOSE statement Submitted By: J3 Status: For Consideration References: Section 9.4.6, page 185 Basic Functionality: A CLOSE with DEFER='YES' sets the parameters (primarily STATUS=) of the CLOSE, the connection is actually closed when a subsequent CLOSE or at program termination. A CLOSE with DEFER='NO' or DEFER= absent is effective immediately (as the present CLOSE statement). Rationale: A program may write a logfile of its actions which is desired to be kept only if the program terminates abnormally (this may be especially true of library writers). This functionality was one supporting reason for the proposed named scratch files feature. Other files may be desired to be kept only if the program terminates normally (a very large output file). Adding DEFER=['YES'|'NO'] to CLOSE gives both. An alternative is to add a CLOSE='' to the OPEN statement. However, it seems to me to be desirable to have close specifiers on the close statement, and open specifiers on the open statement, rather than mixing the two. The alternative does allow one statement to do the work of two. An example of the expected use: OPEN( i, 'my_log_file', STATUS='replace') CLOSE( i, STATUS='keep', DEFER='yes') ... ! normal termination CLOSE( i, STATUS='delete') If the program terminates abnormally, the lof file is available for inspection. Otherwise, it is deleted. Estimated Impact: No other statement is affected. The affect on compilers is low, as the compiler must "package" the close parameters for the system close routine anyway. This feature simply requires the processor to keep the user-specified parameters for later use. Detailed Specification: Add DEFER=['YES'|'NO'] to the CLOSE statement. The IOSTAT= variable, if present, should reflect whether legal values are passed to CLOSE only. The IOSTAT= variable on the subsequent close statement, if any, may reflect the status of the actual close. Given DEFER=, if the s-d-c-e with trailing blanks removed, evaluates to 'YES', the close action is deferred until the file is otherwise closed. If the s-d-c-e evaluates to 'NO' with trailing blanks removed, or DEFER= is absent, the close is effective immediately. It may be desirable to add a specifier to the INQUIRE statement to detect when a deferred close has been specified, but this paper does not propose to do so. History: