This LCS details changes for an attribute to provide introspection of record types.

LCS2016069 

1 

04Jan17 

Draft 

Brent Hayhoe 



Record Introspection & Indexing 

Definition of an attribute to enable introspection of record types 
Key:
Replace the LRM 3.2.3 title with:
16.2.3 Predefined attributes of arrays composites
Insert new title after LRM 3.2.3 title:
16.2.3.1 Predefined attributes of arrays
Insert new title before LRM 3.2.4 title:
16.2.3.2 Predefined attributes of records
An implicit enumerated type E is declared whenever a record type R is declared, such that each enumerated literal E'POS(n1) is an identifier identical to the simple name of the nth element of the record type R'NAME(n1).
Annot: how to access record element path with an enumerated type?
selected_name ::= prefix . suffix
suffix ::=
simple_name
 character_literal
 enumeration_identifier
 operator_symbol
 all
R'RECORDS  Kind:  Type. 
Prefix:  Any prefix R that is appropriate for a record object, or an alias thereof, or that denotes a record subtype.  
Result:  The implicit enumerated type E.  
R'NAME [(N)]  Kind:  Function. 
Prefix:  Any prefix R that is appropriate for a record object, or an alias thereof, or that denotes a record subtype.  
Parameter:  A locally static expression of type universal_integer, the value of which shall not exceed the dimensionality of R. If omitted, it defaults to 1.  
Result type:  The implicit enumerated type E.  
Result:  E'POS(N).  
R'LEFT [(N)]  Kind:  Function. 
Prefix:  Any prefix R that is appropriate for a record object, or an alias thereof, or that denotes a record subtype whose index ranges are defined by a constraint.  
Parameter:  A locally static expression of type universal_integer, the value of which shall not exceed the dimensionality of R. If omitted, it defaults to 1.  
Result type:  The implicit enumerated type E.  
Result:  E'LEFT(N).  
R'RIGHT [(N)]  Kind:  Function. 
Prefix:  Any prefix R that is appropriate for a record object, or an alias thereof, or that denotes a record subtype whose index ranges are defined by a constraint.  
Parameter:  A locally static expression of type universal_integer, the value of which shall not exceed the dimensionality of R. If omitted, it defaults to 1.  
Result type:  The implicit enumerated type E.  
Result:  E'RIGHT(N).  
R'HIGH [(N)]  Kind:  Function. 
Prefix:  Any prefix R that is appropriate for a record object, or an alias thereof, or that denotes a record subtype whose index ranges are defined by a constraint.  
Parameter:  A locally static expression of type universal_integer, the value of which shall not exceed the dimensionality of R. If omitted, it defaults to 1.  
Result type:  The implicit enumerated type E.  
Result:  E'HIGH(N).  
R'LOW [(N)]  Kind:  Function. 
Prefix:  Any prefix R that is appropriate for a record object, or an alias thereof, or that denotes a record subtype whose index ranges are defined by a constraint.  
Parameter:  A locally static expression of type universal_integer, the value of which shall not exceed the dimensionality of R. If omitted, it defaults to 1.  
Result type:  The implicit enumerated type E.  
Result:  E'LOW(N).  
R'RANGE [(N)]  Kind:  Range. 
Prefix:  Any prefix R that is appropriate for a record object, or an alias thereof, or that denotes a record subtype whose index ranges are defined by a constraint.  
Parameter:  A locally static expression of type universal_integer, the value of which shall not exceed the dimensionality of R. If omitted, it defaults to 1.  
Result type:  The type of the Nth index range of A.  
Result:  The range R'LEFT(N) to R'RIGHT(N) if the Nth index range of A is ascending, or the range R'LEFT(N) downto R'RIGHT(N) if the Nth index range of A is descending. (If A is an alias for an array object, then the result is determined by the Nth index range from the declaration of A, not that of the object.)  
R'REVERSE_RANGE [(N)]  Kind:  Range. 
Prefix:  Any prefix R that is appropriate for a record object, or an alias thereof, or that denotes a record subtype whose index ranges are defined by a constraint.  
Parameter:  A locally static expression of type universal_integer, the value of which shall not exceed the dimensionality of R. If omitted, it defaults to 1.  
Result type:  The type of the Nth index range of A.  
Result:  The range R'RIGHT(N) downto R'LEFT(N) if the Nth index range of A is ascending, or the range R'RIGHT(N) to R'LEFT(N) if the Nth index range of A is descending. (If A is an alias for an array object, then the result is determined by the Nth index range from the declaration of A, not that of the object.)  
R'LENGTH [(N)]  Kind:  Function. 
Prefix:  Any prefix R that is appropriate for a record object, or an alias thereof, or that denotes a record subtype whose index ranges are defined by a constraint.  
Parameter:  A locally static expression of type universal_integer, the value of which shall not exceed the dimensionality of R. If omitted, it defaults to 1.  
Result type:  universal_integer.  
Result:  Number of values in the Nth index range; i.e., if the Nth index range of A is a null range, then the result is 0. Otherwise, the result is the value of T'POS(R'HIGH(N)) – T'POS(R'LOW(N)) + 1, where T is the subtype of the Nth index of A.  
R'ASCENDING [(N)]  Kind:  Function. 
Prefix:  Any prefix R that is appropriate for a record object, or an alias thereof, or that denotes a record subtype whose index ranges are defined by a constraint.  
Parameter:  A locally static expression of type universal integer, the value of which shall be greater than zero and shall not exceed the dimensionality of A. If omitted, it defaults to 1.  
Result type:  Type BOOLEAN.  
Result:  TRUE if the Nth index range of A is defined with an ascending range; FALSE otherwise.  
R'ELEMENT  Kind:  Subtype. 
Prefix:  Any prefix R that is appropriate for a record object, or an alias thereof, or that denotes a record subtype.  
Result:  If A is an array subtype, the result is the element subtype of A. If A is an array object, the result is the fully constrained element subtype that is the element subtype of A, together with constraints defining any index ranges that are determined by application of the rules of 5.3.2.2. (If A is an alias for an array object, then the result is determined by the declaration of A, not that of the object.) 
This proposal is based on the idea that these attributes can be used within a forloop. The iterator of a forloop is not locally static so it's unusable as an argument of an attribute. So, you can add these attributes but you will not achieve your usecase.
 Lieven Lemiengre  20170109
Is this the same for arrays as well?