Language Change Specification for Attribute Shorthands

LCS Number: LCS-2016-018b
Version: 1 {04-Jan-2017}
Date: 04-Jan-2017
Status: Voting
Author: Patrick Lehmann
Email: Main.PatrickLehmann
Source Doc: Attributes for Enumerated Types
Summary: Attribute shorthands.

Voting Results: Cast your votes here

Yes:

  1. Patrick Lehmann - 2017-01-04 - ver 1

No:

Abstain:

Style Notes

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

Reviewing Notes

Many attributes are only defined for types. This requires either a type prefix or the use of 'BASETYPE to apply an
attribute to an object. This LCS add attributes for objects, inherited from correnponding types.

Details of Language Change

16.2.3 Predefined attributes of objects [inserted by LCS-2016-018]

[Editor note: Insert this paragraph after the table for O'SUBTYPE.]

If a type T defines an attribute ATTR without any parameter, then an object O of type T shall define an attribute
with same name, kind, result type, result and restrictions. (ATTR is an arbitrary attribute name predefined for T.)
The expression O'ATTR shall be equivalent to O'SUBTYPE'ATTR. As an exception, the attribute 'BASE is not defined
for objects.

If a type T defines an attribute ATTR with one parameter X, which is expected to be of type T, then an object O
of type T shall define an attribute with same name, kind, result type, result and restrictions, but without any parameter.
(ATTR is an arbitrary attribute name predefined for T.) The expression O'ATTR shall be equivalent to O'SUBTYPE'ATTR(O).
As an exception, the attributes 'VALUE and 'VAL are not defined for objects.

Example:

process
  type T is (A, B, C, D);
  variable V1 : T;
  variable V2 : integer := 5;
begin
  -- The following 3 statments are equivalent and report "D".
  report T'image(T'right);
  report T'image(V1'subtype'right);
  report T'image(V1'right);
	
  -- The following 3 statments are equivalent and report "5".
  report integer'image(V2);
  report V2'subtype'image(V2);
  report V2'image;
end process;



Comments

As I read it, this LCS is only trying to provide a shorthand way to retrieve attributes and no new feature. However, this LCS would conflict with LCS-2016-72a which I wrote which uses the same shorthand to deliver a new feature. Specifically, the difference is when one refers to a parameter to a subprogram. In that situation, I would like to have V2'left (as an example) return something different than V2'subtype'left (while leaving the current functionality of V2'subtype'left). I believe that LCS-2016-72a would accomplish the same goal that you have here with this LCS (at least for objects that are scalars), but rather than only providing two methods to accomplish the same goal LCS-2016-072a would provide new functionality. Please review that LCS. At a minimum, the differences between the two should get resolved so that they are not in conflict.

-- Kevin Jennings - 2017-01-04

Edit | Attach | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2020-02-17 - 15:34:41 - TWikiGuest
 
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