comp.lang.ada
 help / color / mirror / Atom feed
From: "G.B." <bauhaus@notmyhomepage.invalid>
Subject: Re: Parameterised 'Image Attributes
Date: Sun, 20 Aug 2023 09:53:11 +0200	[thread overview]
Message-ID: <ubsgp8$19ib8$1@dont-email.me> (raw)
In-Reply-To: <ubqn0t$o3lq$1@dont-email.me>

On 19.08.23 17:27, Jeffrey R.Carter wrote:
> On 2023-08-19 11:14, J-P. Rosen wrote:
>> On 18/08/2023 08:18, Rod Kay wrote:
>>>
>>>     Would it be possible/desirable to allow the 'Image attribute to have formatting parameters ? Something along the lines of ...
>>
>> The intent of the 'Image attribute is to have a quick representation, mainly for debugging purposes. If you want nice formatted output, use the Put procedure on String from Text_IO
> (...)
> The obvious solution is to have a library containing appropriate functions, which can be built around the Put procedures while still being functions. Such functions would need to be generic, unlike attribute functions which are automatically available for all types.
> 
> The conflict between this common need and the minimal functionality provided by 'Image results in such requests. It seems desirable for the language to provide such functions, and extending the 'Image functions seems like a reasonable way for it to do so, regardless of the original intentions for the attribute.

So, also

- See how other languages address formats (good bits,
   bad bits).
- Consider use cases.
- I/O is the program(mer)'s raison d'être. Can we easily Put
   something into a stream without the help of a suitable
   library?

Could there be a language defined type F whose purpose is to support
the description of formats? Objects of type F would "configure"
what 'Image does when computing a representation of a date, a number, ...

   My_Length'Image (Arg => diameter, Format => ___);

Some use cases:
- I18n of number formats (cf ARM F.3), CHF 1'234'000.–
- Handle ubiquitous ISO formats of date-time (as mentioned below;
   also cf. ARM 9.6.1)
- reporting,
- integrate own output with output of other system components
   (a site-wide monitoring system searches outputs, say)
- fill in templates when these do not support formatting
- 'Input an object of type F at run-time, so that program's
   use of 'Image can be changed according to customer's
   local expectations.
- support the formalized exchange of "numerical" data in
   heterogeneous systems, using text streams.

These use cases are about the O of I/O. By symmetry, it would be
nice to have implementations of Ada that support the I part of this
kind of I/O, I think, with work to be split between implementers
and programmers.

   My_Length'Value (Arg => diameter, Format => ___);

Or perhaps multimethods that take a stream and a format
when they need to write a value?


> One library with such functions is the PragmAda Reusable Components (https://github.com/jrcarter/PragmARC). The package PragmARC.Images (https://github.com/jrcarter/PragmARC/blob/Ada-12/pragmarc-images.ads) provides such functions for integer and floating-point types. Function PragmARC.Images.Image is an instantiation for Standard.Integer.
> 
> PragmARC.Date_Handler (https://github.com/jrcarter/PragmARC/blob/Ada-12/pragmarc-date_handler.ads) provides image functions for dates and times; although the language now provides a function for a date-time image, Date_Handler continues to be useful as it provides for customized formats rather than the single format provided by Ada.Calendar.Formatting. Many users also find the semantics of the latter's time-zone parameter to be confusing.
> 
> (ISO/IEC 8652:2023 provides a date-time image function the returns the image for the local time zone, but as there are no compilers* for this version of the language, I don't consider that relevant.


  reply	other threads:[~2023-08-20  7:53 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18  7:18 Parameterised 'Image Attributes Rod Kay
2023-08-18  8:25 ` Luke A. Guest
2023-08-19  9:14   ` J-P. Rosen
2023-08-19 10:03     ` Dmitry A. Kazakov
2023-08-19 11:45       ` Luke A. Guest
2023-08-19 11:56       ` J-P. Rosen
2023-08-19 13:01         ` Dmitry A. Kazakov
2023-08-19 15:27     ` Jeffrey R.Carter
2023-08-20  7:53       ` G.B. [this message]
2023-08-20  9:27         ` Dmitry A. Kazakov
2023-08-21 23:11           ` Randy Brukardt
2023-08-21 23:37           ` Randy Brukardt
2023-08-22  7:38             ` Dmitry A. Kazakov
2023-08-19 16:49     ` moi
2023-08-20  7:25       ` Randy Brukardt
2023-08-20  9:43         ` Dmitry A. Kazakov
2023-08-21 23:34           ` Randy Brukardt
2023-08-22  8:13             ` Dmitry A. Kazakov
2023-08-23 10:20               ` Stephen Davies
2023-08-23 16:16                 ` Dmitry A. Kazakov
2023-08-24 19:59                   ` Stephen Davies
2023-08-25  7:26                     ` Dmitry A. Kazakov
2023-08-25  9:04                       ` Stephen Davies
2023-08-25 13:02                         ` Dmitry A. Kazakov
2023-08-28  9:18                           ` Stephen Davies
2023-08-28 10:58                             ` Dmitry A. Kazakov
2023-08-28 15:42                               ` Stephen Davies
2023-08-28 16:09                                 ` Dmitry A. Kazakov
2023-08-28 17:33                                   ` G.B.
2023-08-28 19:08                                     ` Dmitry A. Kazakov
2023-08-28 17:58                               ` Niklas Holsti
2023-08-28 19:08                                 ` Dmitry A. Kazakov
2023-09-07  1:04                               ` Randy Brukardt
2023-09-07  9:01                                 ` Dmitry A. Kazakov
2023-08-18 18:53 ` Keith Thompson
2023-09-23 10:00 ` Rod Kay
2023-09-26  5:47   ` Vadim Godunko
2023-09-26 10:15     ` Rod Kay
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox