Version 1.3 of ai12s/ai12-0124-1.txt
!standard 3.5(31/2) 14-10-03 AI12-0124-1/02
!class Amendment 14-08-11
!status work item 14-08-11
!status received 14-08-08
!priority Low
!difficulty Easy
!subject Add Object'Image
!summary
Allow the prefix of the Image attribute to be an object.
!problem
GNAT has the attribute Obj'Img, which is very useful for debugging and testing
as it does not require looking up the name of the subtype of Obj. This
is commonly used in GNAT programs. Standard Ada should have something similar.
!proposal
(See Wording.)
!wording
Add somewhere in 3.5: (Note that the attribute list doesn't appear to be in any
obvious order, so perhaps these are best added at the tail end.)
For a prefix X that denotes an object of a scalar type:
X'Image Denotes the result of calling function S'Image on X, where S is the
nominal subtype of X.
[Note: In the unlikely event that AI12-0123-1 was approved, this description
could be simplified to:
X'Image Denotes the result of the subprogram call X'Subtype'Image(X).]
Similar wording is needed for X'Wide_Image and X'Wide_Wide_Image.
!discussion
We use an overloading of the existing attribute Image rather than following
GNAT's lead of Img. Our understanding is that GNAT used Img rather than Image
simply because 4.1.4(12/1) requires that implementation-defined attributes
have different names than language-defined ones. Moreover, Ada generally does
not use abbreviations, and this abbreviation would only save two characters.
This addition is compatible, as subtypes do not allow overloading. Thus, if an
object X hides a subtype X, X'Image is currently illegal (and this would be
a straight extension). If a subtype X hides an object X, no change would occur.
This should be implementable relatively easily, as the Size attribute already
allows both subtypes and objects as the prefix, so there is a similar attribute
to use as a model.
Note that the prefix of an attribute has to be a name, but any expression can
be wrapped in a qualification or type conversion in order to make it a name.
(Of course, in that case, the advantage of not having to know the subtype name
has disappeared.)
!ASIS
No ASIS impact(??). (The attribute name already exists, so it is in the
appropriate enumeration. ASIS does not have separate rules for
individual attributes (if it did, the ones for Image would require change).
!ACATS test
An ACATS C-Test is needed to verify that the attributes are implemented as
specified.
!appendix
****************************************************************
Questions? Ask the ACAA Technical Agent