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

4.31 Attribute Img

The Img attribute differs from Image in that, while both can be applied directly to an object, Img cannot be applied to types.

Example usage of the attribute:

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

which 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.