Overview of Ada 2022
7.1 'Image for all types
It must be a shock to programmers coming from other
languages, such as Python, that in Ada one couldn't directly output the
value of a composite, but had to laboriously write one's own routine
to do it field by field, then repeat if there was nesting of composites.
Such a mechanistic process is more efficiently performed by a compiler
than a programmer. And remember that, prior to Add Object'Image (AI12-0124)
included in the Ada 2012 Technical Corrigendum, there was also the tedium
of having to look up the subtype for an object and use My_Subtype'Image
to obtain the image of an object.
'Image for all types (AI12-0020)
adds the attribute 'Image
for all types (see
It should be a boon for debugging.
Following on from this,
Image attributes of language-defined types (AI12-0304)
requires that 'Image
works for the language
defined container types. This uses the new [ ] array aggregate syntax
from Container aggregates; generalized array aggregates (AI12-0212)
s it uses the form of a named array
[ Key1 => Value1, Key2 => Value2 ]
the form is a positional array aggregate, e.g.:
[ [ 1, 2 ] , [ 111, 222, 333 ] ]
for null containers
the form is a null array aggregate, i.e.:
Put_Image should use a Text_Buffer (AI12-0340)
adds package Ada.Strings.Text_Buffers
to make it easier for users to redefine 'Image
for their own purposes.
© 2021, 2022 Jeff Cousins