Language Change Specification for New Attributes

LCS Number: LCS-2016-018a
Version: 1 {03-Jan-2017}
Date: 03-Jan-2017
Status: Voting
Author: Patrick Lehmann
Email: Main.PatrickLehmann
Source Doc: Attributes for Enumerated Types
Summary: Adds new attributes.

Voting Results: Cast your votes here

Yes:

  1. Patrick Lehmann - 2017-01-03 - ver 1
  2. Ryan Hinton - 2017-01-03 - ver 1
  3. Jim Lewis - 2017-01-04 - ver 1
  4. Kevin Jennings - 2017-01-05 - ver 1
  5. Martin Zabel - 2017-01-09 - ver 1
  6. Thomas Preusser - 2017-01-13 - ver 1
  7. Rob Gaddi - 2017-01-15 - ver 1
  8. Lieven Lemiengre - 2017-01-27 - ver 1
  9. Hendrik Eeckhaut - 2017-01-27 ver 1

No:

Abstain:

  1. Brent Hayhoe - 2017-02-16 Version 1 - Abstain due to lack of personal time for review.

Style Notes

Changes are shown in red font.
Deletions are crossed out.
Editing or reviewing notes in green font.

Reviewing Notes

While writing LCS-2016-59 (Improved Type Generics), I figured out that array objects define a 'ELEMENT attribute to access the elements
type, but it's not possible to access the indices type. This LCS adds a 'INDEX attribute.

This LCS is required by LCS-2016-059a, which was separated due to this missing attribute.

Details of Language Change

16.2.3 Predefined attributes of arrays

[Editor note: This sub-section might be renamed by LCS-2016-018 to 16.2.4.]
[Editor note: Insert the next table before table for A'ELEMENT.]

A'INDEX[(N)] Kind: Subtype
  Prefix: Any prefix A that is appropriate for an array object, or an alias
thereof, or that denotes an array subtype.
  Parameter: A locally static expression of type universal_integer, the value
of which shall not exceed the dimensionality of A. If omitted, it defaults to 1.
  Result: The subtype of the Nth index range of A. (If A is an alias for an array
object, then the result is determined by the declaration of A, not that of the object.)

Comments

Judging from the current text of the other array index-related constraints ('left, 'high, etc.), very simple language should suffice to describe the result. I have edited the proposal with the language I think is best. I also changed the name of the attribute to be similar to 'element and 'base.

-- Ryan Hinton - 2017-Jan-03

Isn't A'INDEX(N) equivalent to A(N)'SUBTYPE? If it is equivalent, then why is this LCS needed? If it is different, can you explain how it is different and I'll probably switch from 'No' to 'Yes' vote.

-- Kevin Jennings - 2017-01-05

In short NO :).
A(N)'SUBTYPE returns the subtype of an element, not the subtype of an array index range.
Example: type arr is array(natural range 0 to 7, natural range 0 to 3) of bit;

  • arr'ELEMENT returns the elements subtype -> bit
  • arr(N)'SUBTYPE returns the subtype of the Nth element (same as above)
  • arr'RANGE returns the range of =arr='s index, but not it's subtype, thus the range can not be used to get an index type alias or subtype
The following code is not valid: (sub)type idx is arr'RANGE;
And this code creates a different incompatible type: type idx is range arr'LOW to arr'HIGH;
Both idx definitions (if working) cannot be used to index an element in an array of type arr.
So in conclusion, a handle to an arrays index type is needed.

-- Patrick Lehmann - 2017-01-05

Topic revision: r16 - 2017-04-02 - 15:37:46 - PatrickLehmann
 
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback