J3/98-226 Date: 10th November 1998 To: J3 From: Malcolm Cohen Subject: Fixes for SELECT TYPE This paper considers the issues raised by 98-205 and 98-206 and resolves them (except for issue 60). (1) 98-206 item 1.1 No further edit required, the editor's rewording was acceptable. All further items from 98-206 are considered under their 98-205 issue no. (2) Issue 53, terminology The /DATA subgroup's opinion is that we should keep the existing terminology. (3) Issue 54, bnf for SELECT TYPE The first two edits from item 2.2 are wordsmithing only, and need not be done at this stage (they can be considered at a later date). The remaining edits are accepted (with typos corrected), viz: [144:35] Change "" to "". [145:3+] Add "R818a <> END SELECT [ ] Constraint: If the of a is identified by a , the corresponding shall specify the same . If the of a is not identified by a , the corresponding shall not specify a . If a specifies a , the corresponding shall be identified by the same ." (4) Issue 55, evaluation of SELECT TYPE operand Rewrite bnf and description to split the expression and variable cases appropriately. This introduces a new term for the SELECT TYPE operand, viz "type selector". [144:36] Change "" to "" [144:37+] Insert "R817a <> <> " [144:38] Change "" to "" [145:20-27] Replace with "Execution of a SELECT TYPE construct whose type selector is not a causes the type selector expression to be evaluated." [327:43-47] Replace "" with "type selector" throughout. (5) Issue 56, bounds, usage and scoping effects of Accept first edit from 98-206 item 2.4, viz [145:30] Change "extents" to "bounds". Note that splitting the bnf for SELECT TYPE on a variable allows us to reword the prohibition against assignment into a constraint, changing a runtime test into a compile-time test (i.e. making it safe). [144:37++] Insert (after [144:37+] edit above) "Constraint: If is not a , shall not appear in a variable definition context (14.7.7)." Since the bnf is not always present, define a new term to cover the actual associate name whether explicit or implicit. [145:17-18] Replace with "The <> of a SELECT TYPE construct is the if specified; otherwise it is the that constitutes the ." [145:28-31] Replace "" with "associate name" throughout. [327:43-44] Replace first sentence with "Execution of a SELECT TYPE statement establishes an association between the type selector and the associate name of the SELECT TYPE construct. Within the construct any entity of the enclosing scoping unit that has this as its name is inaccessible by that name." [327:44-47] Replace "" with "associate name" throughout. [359:29+] Add term to glossary "<> (8.1.4.1) The name by which the type selector of a SELECT TYPE construct is known within the construct." Cover the more general case of definability: [145:30-31] Replace "If ... assignable." with "If the type selector is not definable, its associate name is not definable." [335:40] Replace "." with ", or (11) A in a in a SELECT TYPE construct if the associate name of that construct appears in a variable definition context." (6) Issue 57, WITH statement functionality for non-extensible types The constraint is unnecessary and confusing. [145:1-16] Delete. Also, fix the confusing explanation and delete the confusing array sectioning in the example of this usage: [147:28-29] Change "the type ... type" to "a non-polymorphic type selector" [147:32] Delete "(1:3)" twice. (7) Issue 58, matching the type guard statements to the selector Note: No need to do the first edit from 98-206 item 2.6 (changing text into bnf) as this is not a constraint. Firstly, require TYPE IN to specify an extensible type name; for non- extensible types it was just an alternative (and confusing) spelling for TYPE IS. [144:40] Change "" to "" [144:41+] Insert "Constraint: shall be the name of an extensible type." Secondly, allow TYPE IS and TYPE IN to specify the same type; this is useful. [144:45] Replace "" with "TYPE IS and shall not be specified in more than one TYPE IN " [146:1-25] Replace with: "The type guard statement that matches the type selector is determined as follows: (1) If the dynamic type of the type selector is the same as the type named in a TYPE IS type guard statement, that statement matches; or (2) If the dynamic type of the type selector is not the same as any type named in a TYPE IS type guard statement, and (i) the dynamic type of the type selector is an extension of exactly one type named in a TYPE IN type guard statement, that statement matches; or (ii) the dynamic type of the type selector is an extension of several types named in TYPE IN type guard statements, the type guard statement whose specified type is an extension of all the other types specified in this set of type guard statements matches; or (3) If the dynamic type of the type selector is not the same as any type named in a TYPE IS type guard statement, and is not an extension of any type named in a TYPE IN type guard statement, and there is a TYPE DEFAULT type guard statement, that statement matches. If a type guard statement matches, the block following that statement is executed. NOTE: This algorithm picks the most specific type guard when there are several potential matches. Within the block following a TYPE IS type guard statement, the associate name is not polymorphic and has the type named in the type guard statement. Within the block following a TYPE IN type guard statement, the associate name is a polymorphic object (5.1.1.8) whose declared type is the type named in the type guard statement and whose dynamic type is the same as the dynamic type of the type selector. Within the block following a TYPE DEFAULT type guard statement, the associate name has the same type (both declared and dynamic) as the type selector, and is polymorphic if and only if the type selector is polymorphic." (8) Issue 59, declared type of an expression. [103:24+] Insert "The declared type and dynamic type of an expression are determined as follows: (1) If the expression is an object, the same as the object; or (2) If the expression is a reference to a function (including defined operations), the same as the function result; otherwise (3) the declared type and the dynamic type are the same as the type (7.1.4)." COMMENT: The only functions that can be polymorphic are pointer functions, and the only thing you can do with the result are to be the target in a pointer assignment, the type selector of a SELECT TYPE, or passed on as an actual argument; however, this does not make such a function reference any less polymorphic or any less an expression. [361:30+] Insert "The declared type of an expression is defined in 7.1.1, and may differ from the dynamic type for polymorphic pointer function references." [362:21+] Insert "The dynamic type of an expression is defined in 7.1.1 and may differ from the declared type for polymorphic pointer function references." (9) Issue 60, associate name scoping [324:21-22] Replace with "The associate name of a SELECT TYPE construct has a separate scope for each block in the construct. Within each block, it is a variable having the declared type, dynamic type, type parameters and bounds specified in 8.1.4.2."