08-291 To: J3 From: Malcolm Cohen Subject: Intrinsic inquiry functions in init exprs Date: 2008 November 04 1. Introduction The definition of specification inquiry has changed between F2003 and the F2008 draft. It now includes functions that it ought not to. 2. Discussion Informally, inquiry functions were things that are supposed to be "safe". We actually say "whose result depends on the properties of one or more of its arguments instead of their values". Unfortunately, we have gone ahead and classified several argumentless intrinsic functions as "inquiry", which not only fails to satisfy the definition, but allows them to appear in initialization expressions even though their values are not compile-time determinable. The functions in question are: COMMAND_ARGUMENT_COUNT() THIS_IMAGE() Note that COMMAND_ARGUMENT_COUNT was faulty in F2003 also in that it did not satisfy the definition of an inquiry function. However, it was not permitted in an initialization expression so this was not a critical flaw. Furthermore, the classification of intrinsic procedures omits the case of "pure subroutine". This ought to be repaired. 3. Strategies for repair There are several different ways that these functions could be prohibited from appearing in initialization expressions, but that would still leave the contradiction between the definition of "inquiry" in 13.1 and the function classifications. Therefore these functions should be reclassified. The simplest reclassification is as transformational; that still requires (very few) words in the definition of an initialization expression to exclude them. An alternative strategy would be to notice that the classification "transformational" serves three conflicting purposes: (1) allowance in init exprs when all arguments are init exprs; (2) "miscellaneous" category catching all functions not suitable for inquiry or elemental; (3) doing something transformational producing or consuming an array: this is what the actual definition (and the name) alludes to! If we had a good name for (1), we could use "miscellaneous" or "other" for (2) ... and ignore (3) because that aspect isn't used except to confuse the reader. A third strategy would be to keep the name "transformational" for item (1), and to introduce a different term for the problematic functions. This could be "environmental", "runtime" or simply "miscellaneous". 4. Edits for simple repair strategy [150:7.1.12p1(6)] Change "other than NULL" to "other than COMMAND_ARGUMENT_COUNT, NULL, and THIS_IMAGE". {Argumentless transformationals need exclusion from this item.} [313:13.1p1] Replace the whole paragraph with "Intrinsic procedures are divided into six classes: inquiry functions, elemental functions, transformational functions, elemental subroutines, pure subroutines, and (impure) subroutines." {Improve wording as well as listing all the actual classifications we use. The word "impure" is parenthesised to indicate that we don't use the word in the classification, but that it is nonetheless the case.} [316:13.5p2] "a subroutine but not pure" -> "an impure subroutine". {Random wording improvement.} [317:13.5 Table 13.1, COMMAND_ARGUMENT_COUNT entry] "I" -> "T". {Change class.} [322:13.5 Table 13.1, both THIS_IMAGE entries] "I" -> "T". {Change class.} [337:13.7.37p2] "Inquiry" -> "Transformational". {Change class of COMMAND_ARGUMENT_COUNT.} [337:13.7.164p2] "Inquiry" -> "Transformational". {Change class of THIS_IMAGE.} 5. Edits for third repair strategy These edits choose "miscellaneous functions" to classify intrinsic functions that are not suitable for inclusion in an initialization expression. We don't absolutely need a definition (the normal English meaning is being used), but one is provided for clarity. [311:13.1p1] Replace the whole paragraph with "Intrinsic procedures are divided into seven classes: inquiry functions, elemental functions, transformational functions, miscellaneous functions, elemental subroutines, pure subroutines, and (impure) subroutines." {Improve wording, list all the actual classifications we use, add new class.} [313:13.1p2] Change "All other" -> "Some". Before "All standard" insert "Other intrinsic functions are classified as <>." {Not all other intrinsic functions are transformational; add sentence about miscellaneous.} [316:13.5p2] In the description of the Class column, add new item alphabetically "M indicates that the procedure is a miscellaneous function". [316:13.5p2] "a subroutine but not pure" -> "an impure subroutine". {Random wording improvement.} [317:13.5 Table 13.1, COMMAND_ARGUMENT_COUNT entry] "I" -> "M". {Change class.} [322:13.5 Table 13.1, both THIS_IMAGE entries] "I" -> "M". {Change class.} [337:13.7.37p2] "Inquiry" -> "Miscellaneous". {Change class of COMMAND_ARGUMENT_COUNT.} [337:13.7.164p2] "Inquiry" -> "Miscellaneous". {Change class of THIS_IMAGE.} ===END===