J3/13-242 To: J3 From: Malcolm Cohen Subject: Interp F03/0047 Date: 2013 February 12 ---------------------------------------------------------------------- NUMBER: F03/0047 TITLE: Polymorphic arguments to intrinsic procedures KEYWORDS: polymorphism, intrinsic procedures DEFECT TYPE: Interpretation STATUS: J3 consideration in progress QUESTION: The descriptions of the intrinsic procedures often use the term "type" without qualification. It is unclear whether they mean "declared type" or "dynamic type". If they mean "dynamic type", then this would appear to allow unlimited polymorphic arguments to intrinsic procedures like ABS and SIN. Resolution of generic intrinsic procedures in this case would create an undue (and likely unintended) burden on the processor, and the declared type of the result of such a function call would be unclear as well. Question 1: Are the arguments of the intrinsic functions ALLOCATED, ASSOCIATED, LBOUND, SHAPE, SIZE, and UBOUND permitted to be polymorphic? Question 2: (a) Is the ARRAY argument of the intrinsic function CSHIFT permitted to be polymorphic? If so: (b) If the argument is polymorphic, is the result polymorphic? What are the declared and dynamic types of the result? Question 3: (a) Are the ARRAY and BOUNDARY arguments of the intrinsic function EOSHIFT permitted to be polymorphic? If so: (b) If one of these arguments is polymorphic, then must the other be polymorphic? (c) Do the requirements on their types refer to their declared types or dynamic types? (d) If either argument is polymorphic, is the result polymorphic? What are the declared and dynamic types of the result? Question 4: (a) Are the A and MOLD arguments of the intrinsic function EXTENDS_TYPE_OF permitted to be polymorphic? If so: (b) If one of these arguments is polymorphic, must the other be polymorphic? (c) Do the requirements on their types refer to their declared types or dynamic types? Question 5: (a) Are the TSOURCE and FSOURCE arguments of the intrinsic function MERGE permitted to be polymorphic? If so: (b) If one of these arguments is polymorphic, must the other be polymorphic? (c) Do the requirements on the types of the arguments refer to their declared types or dynamic types? (d) If either argument is polymorphic, is the result polymorphic? What are the declared and dynamic types of the result? Question 6: Are the FROM and TO arguments of the intrinsic function MOVE_ALLOC permitted to be polymorphic? Question 7: (a) Are the ARRAY and VECTOR arguments of the intrinsic function PACK permitted to be polymorphic? If so: (b) If one of these arguments is polymorphic, must the other be polymorphic? (c) Do the requirements on the types of the arguments refer to their declared types or dynamic types? (d) If either argument is polymorphic, is the result polymorphic? What are the declared and dynamic types of the result? Question 8: (a) Are the SOURCE and PAD arguments of the intrinsic function RESHAPE permitted to be polymorphic? If so: (b) If one of these arguments is polymorphic, must the other be polymorphic? (c) Do the requirements on the types of the arguments refer to their declared types or dynamic types? (d) If either argument is polymorphic, is the result polymorphic? What are the declared and dynamic types of the result? Question 9: (a) Are the A and B arguments of the intrinsic function SAME_TYPE_AS permitted to be polymorphic? If so: (b) If one of these arguments is polymorphic, must the other be polymorphic? (c) Do the requirements on their types refer to their declared types or dynamic types? Question 10: (a) Is the SOURCE argument of the intrinsic function SPREAD permitted to be polymorphic? If so: (b) If the argument is polymorphic, is the result polymorphic? What are the declared and dynamic types of the result? Question 11: (a) Is the SOURCE argument of the intrinsic function TRANSFER permitted to be polymorphic? (b) Is the MOLD argument of the intrinsic function TRANSFER permitted to be polymorphic? If the answer to (b) is yes: (c) If the MOLD argument is polymorphic, is the result polymorphic? What are the declared and dynamic types of the result? Question 12: (a) Is the MATRIX argument of the intrinsic function TRANSPOSE permitted to be polymorphic? If so: (b) If the argument is polymorphic, is the result polymorphic? What are the declared and dynamic types of the result? Question 13: (a) Are the VECTOR and FIELD arguments of the intrinsic function UNPACK permitted to be polymorphic? If so: (b) If one of these arguments is polymorphic, must the other be polymorphic? (c) Do the requirements on the types of the arguments refer to their declared types or dynamic types? (d) If either argument is polymorphic, is the result polymorphic? What are the declared and dynamic types of the result? Question 14: Are any of the other arguments of any intrinsic procedure permitted to be polymorphic? ANSWER: The assertion that it is unclear whether "type" means declared, dynamic, or both, is misguided. The general rule is that wherever it makes sense, it means both. Where only one meaning makes sense, it means that one. Where only one meaning is intended but it would otherwise not be clear from context, it is qualified as "declared type" or "dynamic type". Answer 1: Yes. Answer 2: (a) Yes. (b) Yes. "The result is of the type ... of ARRAY". Answer 3: (a) Yes. (b) No. (c) The requirements apply to both the declared type and the dynamic type. (d) "The type has ... the type ... of ARRAY". Therefore it is polymorphic if ARRAY is polymorphic. Answer 4: (a) Yes. (b) No. (c) The requirements refer to the declared type; this is explicitly stated. Answer 5: (a) Yes. (b) No. (c) The requirements refer to both the declared type and the dynamic type. Note that this means that if only one argument is polymorphic, it is required to have the same dynamic type as the declared type. (d) The result characteristics are the "Same as TSOURCE", therefore it is polymorphic if TSOURCE is polymorphic. Answer 6: Yes. Answer 7: (a) Yes. (b) No. (c) The requirements refer to both the declared type and the dynamic type. Note that this means that if either ARRAY or VECTOR is not polymorphic, the requirement for type matching means that the dynamic type of the polymorphic argument is known. (d) The result "has the same type" as ARRAY, and therefore is polymorphic if ARRAY is polymorphic. Answer 8: (a) Yes. (b) No. (c) The requirements refer to both the declared type and the dynamic type. (d) The result "has the same type" as SOURCE, and therefore is polymorphic if and only if SOURCE is polymorphic. Answer 9: (a) Yes. (b) No. (c) The requirements are explicitly stated to refer to the declared type. Answer 10: (a) Yes. (b) Yes. "The result is ... of the same type ... as ARRAY.". Answer 11: (a) Yes. (b) Yes. (c) "The result is of the same type ... as MOLD.". Answer 12: (a) Yes. (b) Yes. Answer 13: (a) Yes. (b) Yes. (c) The requirements refer to both the declared type and the dynamic type. (d) The result has the same type as VECTOR. Answer 14: Yes. For example, IMAGE_INDEX, LCOBOUND, PRESENT, STORAGE_SIZE, and UCOBOUND. EDITS: None. SUBMITTED BY: Rob James HISTORY: 05-138 m171 F03/0047 submitted - contained the questions/answers 05-138r1 m171 Contained the edits, passed by J3 meeting 05-170 m172 Passed J3 letter ballot #11 N1622 m172 Failed WG5 ballot N1629 13-nnn m200 Revised ----------------------------------------------------------------------