11-181 To: J3 From: Nick Maclaren Subject: Interop TR: abolishing the type member Date: 2011 June 11 Reference: N1854, N1820, 11-173, 11-178 Question: Why is ithe type member there in the first place? Answer: Because we agreed it in requirement 2 of N1820: If it is reasonably feasible, a mechanism should be provided for C function to specify by explicit declaration the type or rank (both preferred) of an assumed-shape, allocatable, or pointer object. The objective is to provide a facility for type and rank safety. It is not explicitly in the purpose of the TR, but that requirement was (and is) agreed to be a good idea, and I am not challenging it. However, the current TR and even 11-173 proposes to provide type-safety only for the standard C types that are interoperable with Fortran, despite the fact that assumed-type is more general. I do not regard that as an adequate level of type-safety, and therefore feel that it does not deliver on that requirement. Furthermore, its current specification makes it impossible for conforming compilers to extend it to other types. This paper proposes to simply abolish it, as has been mooted before, but I believe not formally proposed. Note that I am NOT saying that the type member could not be added back in a future development. The biggest consequential change is that specifying the element length is required consistently for all types, which is in itself a significant simplification of the TR. Virtually all of the edits are simple deletions, and no examples become unimplementable, though one needs an extra argument to make sense. I have given the elem_len changes in replacement form, as reordering two sentences after the deletions makes them clearer. Note that it does NOT duplicate the corrections in 11-178. Edits to N1854 -------------- [9:9] Replace ", CFI_rank_t, and CFI_type_t" by "and CFI_rank_t". [10:11-15] Delete the definition of the type member. [11:16-12:0+] Delete paragraph 7, table 5.2 and note 5.5. [13:0+] Delete the definition of CFI_INVALID_TYPE. [14:27-30] Replace the specification of elem_len by: "If the object is of Fortran character type, the value of elem_len shall be the number of characters in an element of the object times the sizeof() of a scalar of the character type; otherwise, elem_len shall be greater than zero and equal to the sizeof() of an element of the object." [15:29] Delete "CFI_type_t type,". [16:2] Replace "the specified type" by "the type it is accessed as". [16:6] Delete the line "type shall be one of the type codes in Table 5.2." [16:7-10] Replace the specification of elem_len by: "If the object is of Fortran character type, the value of elem_len shall be the number of characters in an element of the object times the sizeof() of a scalar of the character type; otherwise, elem_len shall be greater than zero and equal to the sizeof() of an element of the object." [16:29] Delete "CFI_type_double,". [16:45] Delete "CFI_type_other,". [18:5] Delete "CFI_type_t type,". [18:16] Delete the line "type shall be one of the type codes in Table 5.2. It specifies the type of the array section." [18:19] Replace "the specified type" by "the type it is accessed as". [18:21-25] Replace the specification of elem_len by: "If the array section is of Fortran character type, the value of elem_len shall be the number of characters in an element of the array section times the sizeof() of a scalar of the character type; otherwise, elem_len shall be greater than zero and equal to the sizeof() of an element of the array section. The value of elem_len shall be between 1 and source->elem_len inclusive." [19:4] Delete "CFI_type_double_complex," [19:41] Replace "specified in its type member" by "it is accessed as". [21:1-5] Delete from "; the type member" to "CFI_type_other". [31:11] Delete "type,". [35:24] Replace "C)" by "C, D)". [35:27+] Add the line: "character(kind=c_char,len=*), intent(in) :: D [35:32+] Add the line: "#include " [35:36] Replace ") {" by ", const char * typename) {". [35:47-48] Replace "if (a_desc->type != CFI_type_int || b_desc->type != CFI_type_int || c_desc->type != CFI_type_int) {" by: "if (strcmp(typename,"int") != 0 || a_desc->elem_len != sizeof(int) || b_desc->elem_len != sizeof(int) || c_desc->elem_len != sizeof(int)) {" [38:18] Delete "CFI_type_double,". [38:29] Delete "CFI_type_double,". [39:16] Delete "int_array->type,". [40:15] Delete "CFI_type_int,". [40:41] Delete "CFI_type_int,".