J3/13-214 To: J3 From: Van Snyder Subject: Protected types Date: 2013 December 19 Reference: 04-167; 2004 hate-dislike-like-love score 0-0-11-0 Title: Protected types Submitted by: Van Snyder Status: For consideration Basic functionality: Define a PROTECTED attribute for types. Rationale: The PROTECTED attribute cannot protect a linked list that is traversed using a pointer. The PROTECTED attribute for a type would improve performance and reduce labor cost by not requiring PRIVATE components and trivial "read" functions. Estimated impact: Minor Markham M6 conformance: Remove simple deficiency and discrepancy. Detailed specification: Define a PROTECTED attribute for types. If a type has the PROTECTED attribute and the type definition is accessed by use association: o a nonpointer dummy argument of the type shall have INTENT(IN), { this isn't strictly necessary but might improve error reporting } o a variable of the type shall not be storage associated, { this is stronger than the PROTECTED attribute for variables, which prohibits common but admits equivalence } o a variable of the type or a subobject of a variable of the type shall not appear in a variable definition context (16.6.7), and o a subobject of a variable of the type shall not appear in a pointer association context (16.6.8). This allows a pointer outside the module where the type is defined to step through a linked list, but prohibits revising pointers or component values within the list. Draft edits: To estimate scope of project Insert an alternative for R427 <> ABSTRACT ... <> PROTECTED Within 5.3.15: Insert a <<5.3.15.1 General>> subclause, encompassing the introductory blather of 5.3.15, C548 and C549. Within C549, replace "procedure pointer or variable" by "procedure pointer, variable, or derived type definition". Insert a <<5.3.15.2 PROTECTED attribute for variables and procedure pointers>> subclause heading after C549. After 5.3.15p3 insert a <> subclause The PROTECTED attribute for a type imposes limitations on the usage of variables of the type if the type is accessed by use association. C552a If the definition of a type that has the PROTECTED attribute is accessed by use association o a nonpointer dummy argument of the type shall have INTENT(IN), o a variable of the type shall not be storage associated, o a variable of the type or a subobject of a variable of the type shall not appear in a variable definition context (16.6.7), and o a subobject of a variable of the type shall not appear in a pointer association context (16.6.8). {It isn't necessary, and might be undesirable, to specify that a variable of a type that has the PROTECTED attribute and is accessed by use association has the PROTECTED attribute. One can always specify it explicitly.} If the definition of a type that has the PROTECTED attribute is accessed by use association, a nonpointer object of the type, and its subobjects, are not definable. NOTE 5.21a Unlike a variable with the PROTECTED attribute, a variable of a type with the PROTECTED attribute can be a in a . This allows, for example, to traverse a linked list but prevents changing objects within the list.