Next: , Previous: , Up: Implementation Defined Attributes   [Contents][Index]


4.30 Attribute Img

The Img attribute differs from Image in that it is applied directly to an object, and yields the same result as Image for the subtype of the object. This is convenient for debugging:

Put_Line ("X = " & X'Img);

has the same meaning as the more verbose:

Put_Line ("X = " & T'Image (X));

where T is the (sub)type of the object X.

Note that technically, in analogy to Image, X'Img returns a parameterless function that returns the appropriate string when called. This means that X'Img can be renamed as a function-returning-string, or used in an instantiation as a function parameter.