Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"I'm a mean green mother from outer space" -- Audrey II, The Little Shop of Horrors


devel / comp.lang.ada / Parameterised 'Image Attributes

SubjectAuthor
* Parameterised 'Image AttributesRod Kay
+* Re: Parameterised 'Image AttributesLuke A. Guest
|`* Re: Parameterised 'Image AttributesJ-P. Rosen
| +* Re: Parameterised 'Image AttributesDmitry A. Kazakov
| |+- Re: Parameterised 'Image AttributesLuke A. Guest
| |`* Re: Parameterised 'Image AttributesJ-P. Rosen
| | `- Re: Parameterised 'Image AttributesDmitry A. Kazakov
| +* Re: Parameterised 'Image AttributesJeffrey R.Carter
| |`* Re: Parameterised 'Image AttributesG.B.
| | `* Re: Parameterised 'Image AttributesDmitry A. Kazakov
| |  +- Re: Parameterised 'Image AttributesRandy Brukardt
| |  `* Re: Parameterised 'Image AttributesRandy Brukardt
| |   `- Re: Parameterised 'Image AttributesDmitry A. Kazakov
| `* Re: Parameterised 'Image Attributesmoi
|  `* Re: Parameterised 'Image AttributesRandy Brukardt
|   `* Re: Parameterised 'Image AttributesDmitry A. Kazakov
|    `* Re: Parameterised 'Image AttributesRandy Brukardt
|     `* Re: Parameterised 'Image AttributesDmitry A. Kazakov
|      `* Re: Parameterised 'Image AttributesStephen Davies
|       `* Re: Parameterised 'Image AttributesDmitry A. Kazakov
|        `* Re: Parameterised 'Image AttributesStephen Davies
|         `* Re: Parameterised 'Image AttributesDmitry A. Kazakov
|          `* Re: Parameterised 'Image AttributesStephen Davies
|           `* Re: Parameterised 'Image AttributesDmitry A. Kazakov
|            `* Re: Parameterised 'Image AttributesStephen Davies
|             `* Re: Parameterised 'Image AttributesDmitry A. Kazakov
|              +* Re: Parameterised 'Image AttributesStephen Davies
|              |`* Re: Parameterised 'Image AttributesDmitry A. Kazakov
|              | `* Re: Parameterised 'Image AttributesG.B.
|              |  `- Re: Parameterised 'Image AttributesDmitry A. Kazakov
|              +* Re: Parameterised 'Image AttributesNiklas Holsti
|              |`- Re: Parameterised 'Image AttributesDmitry A. Kazakov
|              `* Re: Parameterised 'Image AttributesRandy Brukardt
|               `- Re: Parameterised 'Image AttributesDmitry A. Kazakov
+- Re: Parameterised 'Image AttributesKeith Thompson
`* Re: Parameterised 'Image AttributesRod Kay
 `* Re: Parameterised 'Image AttributesVadim Godunko
  `- Re: Parameterised 'Image AttributesRod Kay

Pages:12
Parameterised 'Image Attributes

<ubn5un$5tvt$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9934&group=comp.lang.ada#9934

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rodakay5@gmail.com (Rod Kay)
Newsgroups: comp.lang.ada
Subject: Parameterised 'Image Attributes
Date: Fri, 18 Aug 2023 17:18:29 +1000
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <ubn5un$5tvt$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 18 Aug 2023 07:17:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="98acf62e089e070804706cd6bbf41d5b";
logging-data="194557"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18fKt/cmcN4CHBTPdNDmupKXXtw5XP4E9U="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:rF2uHQ5dNeucINESo0J/e895j0k=
Content-Language: en-US
 by: Rod Kay - Fri, 18 Aug 2023 07:18 UTC

Hello.all,

There has been some recent discussion on #ada irc regarding
formatted output.

Would it be possible/desirable to allow the 'Image attribute to have
formatting parameters ? Something along the lines of ...

put_Line (some_Integer'Image (Width => 5, Padding => '0'));

.... and similar 'Image attribute parameters for other types.

If the parameters have defaults, then there should not be any
backwards compatibility issues (I think).

Any thoughts ?

Regards.

Re: Parameterised 'Image Attributes

<ubn9u8$6fup$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9935&group=comp.lang.ada#9935

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: laguest@archeia.com (Luke A. Guest)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Fri, 18 Aug 2023 09:25:44 +0100
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <ubn9u8$6fup$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 18 Aug 2023 08:25:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d6b8f11288c89c64b992283513aef529";
logging-data="212953"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/q3yHJ6aiNg2Lk2Xz6vh/cTum5jxYwOvk="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:A4cEaxEwjpW9jN6ABgxPzhGv68E=
In-Reply-To: <ubn5un$5tvt$1@dont-email.me>
Content-Language: en-GB
 by: Luke A. Guest - Fri, 18 Aug 2023 08:25 UTC

On 18/08/2023 08:18, Rod Kay wrote:
> Hello.all,
>
>
>    There has been some recent discussion on #ada irc regarding
> formatted output.
>
>    Would it be possible/desirable to allow the 'Image attribute to have
> formatting parameters ? Something along the lines of ...
>
>
>    put_Line (some_Integer'Image (Width => 5, Padding => '0'));
>
>
> ... and similar 'Image attribute parameters for other types.
>
>
>    If the parameters have defaults, then there should not be any
> backwards compatibility issues (I think).

I wanted them for ages, but there was a conversation ages ago where
someone on here said attributes were for "debugging only," yet that's
not what the arm says.

Re: Parameterised 'Image Attributes

<87pm3ki3lz.fsf@nosuchdomain.example.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9936&group=comp.lang.ada#9936

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Fri, 18 Aug 2023 11:53:44 -0700
Organization: None to speak of
Lines: 30
Message-ID: <87pm3ki3lz.fsf@nosuchdomain.example.com>
References: <ubn5un$5tvt$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="ed98cb3cb6283a5474b2936d7ca2542f";
logging-data="398367"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184l6FCuAJjd0EeX1JQ1pGY"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:EEQb80PffCPokQbvIigh9jXcfgg=
sha1:+HJ/3fDjD/hWK297E2bteBFJepg=
 by: Keith Thompson - Fri, 18 Aug 2023 18:53 UTC

Rod Kay <rodakay5@gmail.com> writes:
> There has been some recent discussion on #ada irc regarding
> formatted output.
>
> Would it be possible/desirable to allow the 'Image attribute to
> have formatting parameters ? Something along the lines of ...
>
>
> put_Line (some_Integer'Image (Width => 5, Padding => '0'));
>
>
> ... and similar 'Image attribute parameters for other types.
>
>
> If the parameters have defaults, then there should not be any
> backwards compatibility issues (I think).

TeleSoft's compiler (which I worked on) had 'Extended_Image and
'Extended_Value attributes that worked like that. I found them quite
useful -- especially as an easy way to drop the leading space on
Integer'Image.

One small problem was that we had different parameters for integer
and enumeration types, which introduced an ambiguity for discrete
formal types.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: Parameterised 'Image Attributes

<ubq15l$oa8i$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9937&group=comp.lang.ada#9937

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rosen@adalog.fr (J-P. Rosen)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Sat, 19 Aug 2023 11:14:34 +0200
Organization: Adalog
Lines: 30
Message-ID: <ubq15l$oa8i$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 19 Aug 2023 09:14:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5313c0efa581855a557fbab8f534a02e";
logging-data="796946"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19H2+guPlN5g+0MsUEV/0/J"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:3/S/VovpdkOiW4YXAweLBMuIV5w=
In-Reply-To: <ubn9u8$6fup$1@dont-email.me>
Content-Language: en-US, fr
 by: J-P. Rosen - Sat, 19 Aug 2023 09:14 UTC

Le 18/08/2023 à 10:25, Luke A. Guest a écrit :
> On 18/08/2023 08:18, Rod Kay wrote:
>> Hello.all,
>>     There has been some recent discussion on #ada irc regarding
>> formatted output.
>>
>>     Would it be possible/desirable to allow the 'Image attribute to
>> have formatting parameters ? Something along the lines of ...
>>
>>     put_Line (some_Integer'Image (Width => 5, Padding => '0'));
>>
>> ... and similar 'Image attribute parameters for other types.
>>
>>     If the parameters have defaults, then there should not be any
>> backwards compatibility issues (I think).
>
> I wanted them for ages, but there was a conversation ages ago where
> someone on here said attributes were for "debugging only," yet that's
> not what the arm says.
>
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.

--
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
https://www.adalog.fr https://www.adacontrol.fr

Re: Parameterised 'Image Attributes

<ubq40t$ni21$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9938&group=comp.lang.ada#9938

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Sat, 19 Aug 2023 12:03:09 +0200
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <ubq40t$ni21$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 19 Aug 2023 10:03:09 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="316de7f1c065f36c1d679840f6f7de11";
logging-data="772161"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/k2irz75OzziZbn4F/8cTuHnqYQ128YkQ="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:Ml7Dn5bqzgrMaZT5k6qNg2dPvpg=
Content-Language: en-US
In-Reply-To: <ubq15l$oa8i$1@dont-email.me>
 by: Dmitry A. Kazakov - Sat, 19 Aug 2023 10:03 UTC

On 2023-08-19 11:14, J-P. Rosen wrote:

> The intent of the 'Image attribute is to have a quick representation,
> mainly for debugging purposes.

It seems that for the vast majority of Ada users this intent was wrong...

> If you want nice formatted output, use
> the Put procedure on String from Text_IO.

Put does not supersede 'Image. Put is I/O. 'Image is pure string
formatting. Put is generic and requires instantiation of some package
with some difficult to guess name. 'Image is built-in [statically]
dispatching and generated automatically by the compiler.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Parameterised 'Image Attributes

<ubqa15$pkis$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9939&group=comp.lang.ada#9939

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: laguest@archeia.com (Luke A. Guest)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Sat, 19 Aug 2023 12:45:41 +0100
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <ubqa15$pkis$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me> <ubq40t$ni21$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 19 Aug 2023 11:45:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="463a5cdd8deef4d64282dc433db25fff";
logging-data="840284"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18WTPzFd7GEtAnnMUXixPATZA/arYMzYS8="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:CRZ+xjTNyHFB6r8OE6e/LjUc2pk=
Content-Language: en-GB
In-Reply-To: <ubq40t$ni21$1@dont-email.me>
 by: Luke A. Guest - Sat, 19 Aug 2023 11:45 UTC

On 19/08/2023 11:03, Dmitry A. Kazakov wrote:
> On 2023-08-19 11:14, J-P. Rosen wrote:
>
>> The intent of the 'Image attribute is to have a quick representation,
>> mainly for debugging purposes.
>

Where does it say this in the rm? We certainly were not taught that
'image was for debugging at uni.

> It seems that for the vast majority of Ada users this intent was wrong...

Yup.

Re: Parameterised 'Image Attributes

<ubqako$pla9$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9940&group=comp.lang.ada#9940

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rosen@adalog.fr (J-P. Rosen)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Sat, 19 Aug 2023 13:56:14 +0200
Organization: Adalog
Lines: 34
Message-ID: <ubqako$pla9$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me> <ubq40t$ni21$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 19 Aug 2023 11:56:08 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5313c0efa581855a557fbab8f534a02e";
logging-data="841033"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18984UtjI4VewniG6l9s6k8"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:sF2QzPtftO62UZRGv1m1tVGI4XU=
In-Reply-To: <ubq40t$ni21$1@dont-email.me>
Content-Language: en-US, fr
 by: J-P. Rosen - Sat, 19 Aug 2023 11:56 UTC

Le 19/08/2023 à 12:03, Dmitry A. Kazakov a écrit :
> On 2023-08-19 11:14, J-P. Rosen wrote:
>
>> The intent of the 'Image attribute is to have a quick representation,
>> mainly for debugging purposes.
>
> It seems that for the vast majority of Ada users this intent was wrong...
The vast majority of Ada users ignore a number of useful features
provided by the language, and keep asking for improvements that are
already there...
>> If you want nice formatted output, use the Put procedure on String
>> from Text_IO.
>
> Put does not supersede 'Image. Put is I/O. 'Image is pure string
> formatting. Put is generic and requires instantiation of some package
> with some difficult to guess name. 'Image is built-in [statically]
> dispatching and generated automatically by the compiler.
>
Yes, put has nothing to do with 'Image. Yes, put requires instantiation.
So what? Ada is more verbose, in favor of stricter typing. Ease of
reading over ease of writing has always been a major design principle of
Ada - although I confess it had a bad effect on its popularity, people
want to write fast and ignore long term maintenance issues.

If you want formatting on an integer type (with or without IO), you
instantiate Integer_IO. I don't find it hard to guess the name... Maybe
you had something else in mind?

--
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
https://www.adalog.fr https://www.adacontrol.fr

Re: Parameterised 'Image Attributes

<ubqeff$ni22$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9941&group=comp.lang.ada#9941

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Sat, 19 Aug 2023 15:01:36 +0200
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <ubqeff$ni22$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me> <ubq40t$ni21$1@dont-email.me>
<ubqako$pla9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 19 Aug 2023 13:01:35 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="316de7f1c065f36c1d679840f6f7de11";
logging-data="772162"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ih9eL7HIZi9zst/0Iy/jH84LAh9nSoRQ="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:YiEl251vpglo6epe8OWAbvjZQVI=
In-Reply-To: <ubqako$pla9$1@dont-email.me>
Content-Language: en-US
 by: Dmitry A. Kazakov - Sat, 19 Aug 2023 13:01 UTC

On 2023-08-19 13:56, J-P. Rosen wrote:
> Le 19/08/2023 à 12:03, Dmitry A. Kazakov a écrit :
>> On 2023-08-19 11:14, J-P. Rosen wrote:
>>
>>> The intent of the 'Image attribute is to have a quick representation,
>>> mainly for debugging purposes.
>>
>> It seems that for the vast majority of Ada users this intent was wrong...
> The vast majority of Ada users ignore a number of useful features
> provided by the language, and keep asking for improvements that are
> already there...

Or these features are not that useful? Language users and designers have
often different perspectives...

>>> If you want nice formatted output, use the Put procedure on String
>>> from Text_IO.
>>
>> Put does not supersede 'Image. Put is I/O. 'Image is pure string
>> formatting. Put is generic and requires instantiation of some package
>> with some difficult to guess name. 'Image is built-in [statically]
>> dispatching and generated automatically by the compiler.
>>
> Yes, put has nothing to do with 'Image. Yes, put requires instantiation.
> So what? Ada is more verbose, in favor of stricter typing.

I don't see how instantiation is stricter typing. In fact instantiation
introduces overloading (static ad-hoc polymorphism) which was always
frowned upon at as less type safe than overriding.

> Ease of
> reading over ease of writing has always been a major design principle of
> Ada - although I confess it had a bad effect on its popularity, people
> want to write fast and ignore long term maintenance issues.

I don't buy this either. It is

Put (X) vs. X'Image

equally readable and writable. If you refer to the instantiation noise
or with/use clauses you would require to but somewhere far above in the
package. That is not ease of reading. That is just meaningless noise.

> If you want formatting on an integer type (with or without IO), you
> instantiate Integer_IO. I don't find it hard to guess the name... Maybe
> you had something else in mind?

Yes, all other types that might require formatting. I doubt anybody, but
a language lawyer could name the package appropriate for formatting a
fixed-point type without looking into the RM. Which is absolutely
unneeded as 'Image would be perfectly OK if it had necessary parameters.
All that generic text I/O packages are unnecessary as stream I/O case
perfectly illustrates. Ada 95 did stream I/O if not right, but far
better making 'Read, 'Write etc attributes overridable. The problem of
generic mess solved. We do not have and do not need any generics for
stream I/O. Good riddance.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Parameterised 'Image Attributes

<ubqn0t$o3lq$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9942&group=comp.lang.ada#9942

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spam.jrcarter.not@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Sat, 19 Aug 2023 17:27:25 +0200
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <ubqn0t$o3lq$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 19 Aug 2023 15:27:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="cbd554b853755d2a6e60e861e37e3278";
logging-data="790202"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Rn5KgWoa5ihaB8z/QBRnoh6o7GNRbkGM="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:TPTHzS3/EDofntys+c/44tvTZ9U=
In-Reply-To: <ubq15l$oa8i$1@dont-email.me>
Content-Language: en-US
 by: Jeffrey R.Carter - Sat, 19 Aug 2023 15:27 UTC

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.

There is a common problem across many types and problem domains of having a
function that returns a string of an appropriate length representing a value of
the type with desired formatting. Common examples include numeric values, dates,
and times. The resulting string is usually combined with other information into
a message that may be stored in memory for a while, though it is rare for it not
to be output eventually. As an example, the message may be put on a protected
queue for later output by a logging task.

Ada 83 tended not to include anything that the developer could implement; there
was no math library or image functions for dates or times. The 'Image attribute
was provided, but is unsuited for most such uses.

The use of the Text_IO generic sub-pkg Put procedures that output to strings is
not convenient because they are procedures, not functions.

Later versions of Ada included more support for such needs, but not for numeric
values.

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.

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.

(*A compiler for a version of the language implements the entire core language
of that version of the ARM.)

--
Jeff Carter
"The men get one hot meal a day: a bowl of steam."
Take the Money and Run
145

Re: Parameterised 'Image Attributes

<kkca55F9sn7U1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9943&group=comp.lang.ada#9943

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news-2.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: findlaybill@blueyonder.co.uk (moi)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Sat, 19 Aug 2023 17:49:41 +0100
Lines: 39
Message-ID: <kkca55F9sn7U1@mid.individual.net>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net izOmRXUMdxaxZKB29+d0FQQEKHFPf3QsigvCnUxF4OAw0EDXMN
Cancel-Lock: sha1:TBaS6TPcCdb+pwb+Sn9qUqYop8E= sha256:5XzKvVm3+2MNIBGeOILNATkqFLeeTr6M1ZGGg3xw+as=
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
In-Reply-To: <ubq15l$oa8i$1@dont-email.me>
 by: moi - Sat, 19 Aug 2023 16:49 UTC

On 19/08/2023 10:14, J-P. Rosen wrote:
> Le 18/08/2023 à 10:25, Luke A. Guest a écrit :
>> On 18/08/2023 08:18, Rod Kay wrote:
>>> Hello.all,
>>>     There has been some recent discussion on #ada irc regarding
>>> formatted output.
>>>
>>>     Would it be possible/desirable to allow the 'Image attribute to
>>> have formatting parameters ? Something along the lines of ...
>>>
>>>     put_Line (some_Integer'Image (Width => 5, Padding => '0'));
>>>
>>> ... and similar 'Image attribute parameters for other types.
>>>
>>>     If the parameters have defaults, then there should not be any
>>> backwards compatibility issues (I think).
>>
>> I wanted them for ages, but there was a conversation ages ago where
>> someone on here said attributes were for "debugging only," yet that's
>> not what the arm says.
>>
> 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.
>

My code uses 'Image heavily, because it is usually the neatest and the
clearest way to format many strings that mingle words and numbers.

I sometimes have to pass the result of 'Image to a function that
implements the kind of functionality people are asking for,
and it would be even neater and clearer if I could get that with
parameters to 'Image itself.

None of that output has anything to do with debugging.

--
Bill F.

Re: Parameterised 'Image Attributes

<ubsf4e$19bvo$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9944&group=comp.lang.ada#9944

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: randy@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Sun, 20 Aug 2023 02:25:20 -0500
Organization: A noiseless patient Spider
Lines: 90
Message-ID: <ubsf4e$19bvo$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me> <ubq15l$oa8i$1@dont-email.me> <kkca55F9sn7U1@mid.individual.net>
Injection-Date: Sun, 20 Aug 2023 07:25:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="71b51bfe045da1fc830beb0cd87da280";
logging-data="1355768"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+3s4X4X0TAsM5xaLlATEylG1+Ba1/3YfA="
Cancel-Lock: sha1:61Yfy7aCKNthAs8pWqS7YhzwmY4=
X-RFC2646: Format=Flowed; Response
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246
X-Priority: 3
 by: Randy Brukardt - Sun, 20 Aug 2023 07:25 UTC

The profile of the Image attribute is:

X'Image

where X is an object of any type (or value of most types). And the old,
unnecessary form was:
S'Image(X)
where S and X are of any type.

If one tries to add parameters to this, one gives up this nice form for a
mis-mash of profiles for various classes of types. Moreover, the result no
longer composes in the obvious way (necessary to have Image for records and
arrays).

Additionally, one ends up with a magic mechanism that only the compiler can
use. That *never* is a good idea. Especially as there now is a way to allow
Image to support user-defined types. It would seem necessary to also support
user-defined formatting parameters (else one has magic only applicable to a
handful of language defined types).

Attributes do not allow named parameters outside a few special cases, and
*never* allow reordering of parameters. Does that need to change, too?

Float input/output in particular is very large, especially when all of the
formatting options are included. Do you really want to drag that into
*every* Ada program, whether it uses it or not??

'Image is convinient for integer and enumeration output, and one can format
them in the rare case where that is necessary. But it is useless for float
output -- manual reformatting the output of 'Image would round the results
incorrectly.

Ada has few built-in facilities because it's primary purpose is to support
the development of proper ADTs. Ease of writing is not a goal at all, and in
most cases, the extra text is valuable to compilers and tools (even if it is
not so valuable to human readers). If it was up to me, I would eliminate
most of the shortcuts from Ada and require everything to be written out.
(IDEs could/should do most of that for you anyway, so the extra text is not
adding much effort.)

Ergo, I hope this idea is dead-on-arrival. I certainly won't be involved in
it, that's for sure.

Randy.

"moi" <findlaybill@blueyonder.co.uk> wrote in message
news:kkca55F9sn7U1@mid.individual.net...
> On 19/08/2023 10:14, J-P. Rosen wrote:
>> Le 18/08/2023 � 10:25, Luke A. Guest a �crit :
>>> On 18/08/2023 08:18, Rod Kay wrote:
>>>> Hello.all,
>>>> There has been some recent discussion on #ada irc regarding formatted
>>>> output.
>>>>
>>>> Would it be possible/desirable to allow the 'Image attribute to have
>>>> formatting parameters ? Something along the lines of ...
>>>>
>>>> put_Line (some_Integer'Image (Width => 5, Padding => '0'));
>>>>
>>>> ... and similar 'Image attribute parameters for other types.
>>>>
>>>> If the parameters have defaults, then there should not be any backwards
>>>> compatibility issues (I think).
>>>
>>> I wanted them for ages, but there was a conversation ages ago where
>>> someone on here said attributes were for "debugging only," yet that's
>>> not what the arm says.
>>>
>> 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.
>>
>
> My code uses 'Image heavily, because it is usually the neatest and the
> clearest way to format many strings that mingle words and numbers.
>
> I sometimes have to pass the result of 'Image to a function that
> implements the kind of functionality people are asking for,
> and it would be even neater and clearer if I could get that with
> parameters to 'Image itself.
>
> None of that output has anything to do with debugging.
>
> --
> Bill F.
>

Re: Parameterised 'Image Attributes

<ubsgp8$19ib8$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9945&group=comp.lang.ada#9945

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bauhaus@notmyhomepage.invalid (G.B.)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Sun, 20 Aug 2023 09:53:11 +0200
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <ubsgp8$19ib8$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me> <ubqn0t$o3lq$1@dont-email.me>
Reply-To: nonlegitur@notmyhomepage.de
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 20 Aug 2023 07:53:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3b9e818ded4c7241af4a58064e181b99";
logging-data="1362280"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+7hZJy4VJIpoBTjWX15FQOtuiOGX4BPZs="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.14.0
Cancel-Lock: sha1:EpXxkyF2EnVJfzimXWFWMSxUQ0U=
Content-Language: en-US
In-Reply-To: <ubqn0t$o3lq$1@dont-email.me>
 by: G.B. - Sun, 20 Aug 2023 07:53 UTC

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.

Re: Parameterised 'Image Attributes

<ubsmak$1a024$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9946&group=comp.lang.ada#9946

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Sun, 20 Aug 2023 11:27:47 +0200
Organization: A noiseless patient Spider
Lines: 69
Message-ID: <ubsmak$1a024$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me> <ubqn0t$o3lq$1@dont-email.me>
<ubsgp8$19ib8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 20 Aug 2023 09:27:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1833338c996432ee36783c463952eb03";
logging-data="1376324"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/W/HM33YhhnNmvS1QLcDNXbU/aE6JSOlI="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:xRS3sTKplwyU5P3JmUbcXNPuQBY=
Content-Language: en-US
In-Reply-To: <ubsgp8$19ib8$1@dont-email.me>
 by: Dmitry A. Kazakov - Sun, 20 Aug 2023 09:27 UTC

On 2023-08-20 09:53, G.B. wrote:

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

Not without multiple dispatch support and classes:

Type x Format [ x Target ]

Otherwise you get an untyped mess as in C:

printf ("%s", 123);

In the case of 'Image the dispatch is hard-wired. The compiler generates
it according to one of built-in classes like 'integer type'. So yes it
would be no problem to add parameters specific to each of the classes as
well as common parameters like padding or alignment inside a field. But
it will never ever happen.

You seem suggesting a class-wide parameter type instead:

type Format_Type is tagged record
Width : Natural := 0;
Alignment : Alignment_Type := Left;
Padding : Character := ' ';
end record;
type Integer_Format is new Format_Type with record
Plus_Sign : Boolean := False;
Base : Base_Type := 10;
end record;

X'Image (Format => Format_Type'Class)

This still requires a change that will be outright rejected on highest
philosophical grounds. (:-))

However with a Format_Type you do not need 'Image. You can simply use a
binary operation, e.g.

function "/" (Value : Integer; Format : Integer_Format)
return String;

So would do

Put_Line ("X=" & X / (Width=>10, Padding=>'0', Alignment=>Right));

instead of

Put_Line ("X=" & X'Image (Width=>10, Padding=>'0', Alignment=>Right));

Of course it must be generic, which kills all fun.

Ergo

1. Compiler magic is necessary because the language type system is too
weak to express things like formatting.

2. No proposal however useful and reasonable will survive ARG because of #1.

3. Use a library that does the stuff. E.g.

http://www.dmitry-kazakov.de/ada/strings_edit.htm#Integer_Edit

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Parameterised 'Image Attributes

<ubsn75$1a024$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9947&group=comp.lang.ada#9947

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Sun, 20 Aug 2023 11:43:01 +0200
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <ubsn75$1a024$2@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me> <kkca55F9sn7U1@mid.individual.net>
<ubsf4e$19bvo$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 20 Aug 2023 09:43:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1833338c996432ee36783c463952eb03";
logging-data="1376324"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/jsp62yPKNC9hQ4JCLCkcmMP60FvXRmC8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:0aGKG2E+X2dkoHNyo3hqiw5UOY0=
Content-Language: en-US
In-Reply-To: <ubsf4e$19bvo$1@dont-email.me>
 by: Dmitry A. Kazakov - Sun, 20 Aug 2023 09:43 UTC

On 2023-08-20 09:25, Randy Brukardt wrote:

> Additionally, one ends up with a magic mechanism that only the compiler can
> use. That *never* is a good idea.

A better idea would be to improve the language to remove need in magic,
but that is *never* a good idea either! (:-))

> Attributes do not allow named parameters outside a few special cases, and
> *never* allow reordering of parameters. Does that need to change, too?

Elementary! Attribute is just an alternative syntactic form of a
subroutine call. There is no reason why attribute should be limited to
look like FORTRAN IV! (:-))

> 'Image is convinient for integer and enumeration output, and one can format
> them in the rare case where that is necessary. But it is useless for float
> output -- manual reformatting the output of 'Image would round the results
> incorrectly.

Which is why Float 'Image must have parameters!

> Ada has few built-in facilities because it's primary purpose is to support
> the development of proper ADTs. Ease of writing is not a goal at all, and in
> most cases, the extra text is valuable to compilers and tools (even if it is
> not so valuable to human readers).

How is this related to attribute 'Image lacking necessary parameters?
Why generic function having such parameters is OK, while 'Image with
same parameters is not?

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Parameterised 'Image Attributes

<uc0qu4$239o4$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9949&group=comp.lang.ada#9949

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: randy@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Mon, 21 Aug 2023 18:11:19 -0500
Organization: A noiseless patient Spider
Lines: 85
Message-ID: <uc0qu4$239o4$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me> <ubq15l$oa8i$1@dont-email.me> <ubqn0t$o3lq$1@dont-email.me> <ubsgp8$19ib8$1@dont-email.me> <ubsmak$1a024$1@dont-email.me>
Injection-Date: Mon, 21 Aug 2023 23:11:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a646227c24097efbc8783f6ec1cd88e1";
logging-data="2205444"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19h2zaqqIC6z4/b51AfmgYiwsVeucsyu74="
Cancel-Lock: sha1:CF4VoofzKbjNC9xwZECHUE/NDXI=
X-RFC2646: Format=Flowed; Response
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246
X-Priority: 3
 by: Randy Brukardt - Mon, 21 Aug 2023 23:11 UTC

Your #3 is the point of course. If a reasonable library can be written, you
should use that. After all, the Ada philosophy is that it is suspicious to
use any built-in types. Why then should it be less suspicious to use other
things that are built-in??

The best approach for Ada going forward is the add things that make it
easier to build good libraries (as in user-defined literals). And minimize
magic.

Randy.

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:ubsmak$1a024$1@dont-email.me...
> On 2023-08-20 09:53, G.B. wrote:
>
>> 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, ...
>
> Not without multiple dispatch support and classes:
>
> Type x Format [ x Target ]
>
> Otherwise you get an untyped mess as in C:
>
> printf ("%s", 123);
>
> In the case of 'Image the dispatch is hard-wired. The compiler generates
> it according to one of built-in classes like 'integer type'. So yes it
> would be no problem to add parameters specific to each of the classes as
> well as common parameters like padding or alignment inside a field. But it
> will never ever happen.
>
> You seem suggesting a class-wide parameter type instead:
>
> type Format_Type is tagged record
> Width : Natural := 0;
> Alignment : Alignment_Type := Left;
> Padding : Character := ' ';
> end record;
> type Integer_Format is new Format_Type with record
> Plus_Sign : Boolean := False;
> Base : Base_Type := 10;
> end record;
>
> X'Image (Format => Format_Type'Class)
>
> This still requires a change that will be outright rejected on highest
> philosophical grounds. (:-))
>
> However with a Format_Type you do not need 'Image. You can simply use a
> binary operation, e.g.
>
> function "/" (Value : Integer; Format : Integer_Format)
> return String;
>
> So would do
>
> Put_Line ("X=" & X / (Width=>10, Padding=>'0', Alignment=>Right));
>
> instead of
>
> Put_Line ("X=" & X'Image (Width=>10, Padding=>'0', Alignment=>Right));
>
> Of course it must be generic, which kills all fun.
>
> Ergo
>
> 1. Compiler magic is necessary because the language type system is too
> weak to express things like formatting.
>
> 2. No proposal however useful and reasonable will survive ARG because of
> #1.
>
> 3. Use a library that does the stuff. E.g.
>
> http://www.dmitry-kazakov.de/ada/strings_edit.htm#Integer_Edit" rel="nofollow" target="_blank">http://www.dmitry-kazakov.de/ada/strings_edit.htm#Integer_Edit
>
> --
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de
>

Re: Parameterised 'Image Attributes

<uc0sae$23f5l$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9950&group=comp.lang.ada#9950

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: randy@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Mon, 21 Aug 2023 18:34:55 -0500
Organization: A noiseless patient Spider
Lines: 82
Message-ID: <uc0sae$23f5l$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me> <ubq15l$oa8i$1@dont-email.me> <kkca55F9sn7U1@mid.individual.net> <ubsf4e$19bvo$1@dont-email.me> <ubsn75$1a024$2@dont-email.me>
Injection-Date: Mon, 21 Aug 2023 23:34:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a646227c24097efbc8783f6ec1cd88e1";
logging-data="2210997"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vhBDTJEGhqDA3YYROG03l7HWwtXuK4LI="
Cancel-Lock: sha1:sXEMcPDK9kbJsO8fruT82jdZuu4=
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246
X-Priority: 3
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-RFC2646: Format=Flowed; Response
X-MSMail-Priority: Normal
 by: Randy Brukardt - Mon, 21 Aug 2023 23:34 UTC

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:ubsn75$1a024$2@dont-email.me...
> On 2023-08-20 09:25, Randy Brukardt wrote:
>
>> Additionally, one ends up with a magic mechanism that only the compiler
>> can
>> use. That *never* is a good idea.
>
> A better idea would be to improve the language to remove need in magic,
> but that is *never* a good idea either! (:-))

No, I generally agree with this. We probably disagree on what would
consistute an improvement, however. ;-)

>> Attributes do not allow named parameters outside a few special cases, and
>> *never* allow reordering of parameters. Does that need to change, too?
>
> Elementary! Attribute is just an alternative syntactic form of a
> subroutine call. There is no reason why attribute should be limited to
> look like FORTRAN IV! (:-))

That turns out to be a bad idea. The reason people love attributes so is
that they don't have to worry about visibility -- they're always visible.
That is not and cannot be true for subprograms.

For example, the reason that we don't allow user-defined attributes is that
they would compromise portability. Since they're always visible, they could
hide/make illegal attributes that are used in units (like generic units)
that don't know anything about the additions. Moreover, not all attributes
can be described as subprograms given Ada's current rules (reduction
attributes have a type parameter; some of the annex 13 attributes have "any
type" parameters, etc.)

It certainly would be a very bad thing for Janus/Ada, which would have to
have its resolution and subprogram definition mechanisms redesigned. (All
subprograms are materialized in the Janus/Ada symboltable, in particular for
visibility management reasons, and that would not be possible for
attributes. Resolution only works on materialized subprogram definitions.)

>> 'Image is convinient for integer and enumeration output, and one can
>> format
>> them in the rare case where that is necessary. But it is useless for
>> float
>> output -- manual reformatting the output of 'Image would round the
>> results
>> incorrectly.
>
> Which is why Float 'Image must have parameters!

Which is why one shouldn't use Float'Image! ;-)

>> Ada has few built-in facilities because it's primary purpose is to
>> support
>> the development of proper ADTs. Ease of writing is not a goal at all, and
>> in
>> most cases, the extra text is valuable to compilers and tools (even if it
>> is
>> not so valuable to human readers).
>
> How is this related to attribute 'Image lacking necessary parameters? Why
> generic function having such parameters is OK, while 'Image with same
> parameters is not?

It's perfectly OK to overload functions however one wants, because you can
keep anything that is problem from being considered by avoiding "use" (and
"with").

'Image is not appropriate for an attribute in the first place; attributes
are supposed to be simple compile-time defined properties of a type. String
conversion is not that.

My preference for making Ada easier to use for this sort of thing is allow
class-wide elementary types. Then one could have non-generic subnprograms
that operation on all integer and float types. (Fixed and enumerations would
still require generics, although I suspect most people would simply convert
fixed to float for output rather than worrying about an instantiation.) That
would make a library simple to use, and few people would think that
something builr-in is needed.

Randy.

Re: Parameterised 'Image Attributes

<uc0sfl$23foj$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9951&group=comp.lang.ada#9951

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: randy@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Mon, 21 Aug 2023 18:37:43 -0500
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <uc0sfl$23foj$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me> <ubq15l$oa8i$1@dont-email.me> <ubqn0t$o3lq$1@dont-email.me> <ubsgp8$19ib8$1@dont-email.me> <ubsmak$1a024$1@dont-email.me>
Injection-Date: Mon, 21 Aug 2023 23:37:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a646227c24097efbc8783f6ec1cd88e1";
logging-data="2211603"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18QrID0+hVLBPaCUV1dnRBRGd8A5G3uigI="
Cancel-Lock: sha1:dqR6GyPXRP8CExuL1C8h/KsBmOc=
X-RFC2646: Format=Flowed; Response
X-MSMail-Priority: Normal
X-Priority: 3
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246
 by: Randy Brukardt - Mon, 21 Aug 2023 23:37 UTC

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:ubsmak$1a024$1@dont-email.me...
....
> Of course it must be generic, which kills all fun.

As noted in my other message, resurrecting the Ada 95 idea allowing
class-wide types for elementary types would eliminate (or at least greatly
reduce) this problem. I think that would be a more productive way to address
this problem than hacking around with 'Image some more. (We've already
proven that it is not a good way to define anything user-defined, thus the
rather complex way to define such 'Image attributes.)

Randy.

Re: Parameterised 'Image Attributes

<uc1olt$2anmi$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9952&group=comp.lang.ada#9952

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Tue, 22 Aug 2023 09:38:38 +0200
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <uc1olt$2anmi$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me> <ubqn0t$o3lq$1@dont-email.me>
<ubsgp8$19ib8$1@dont-email.me> <ubsmak$1a024$1@dont-email.me>
<uc0sfl$23foj$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 22 Aug 2023 07:38:37 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="68fb8d4c60f45eceaa1fe84bc52eb712";
logging-data="2449106"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19aikdfYGMmBYr2DwV138sLbv/IjuefSs0="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:x5Gpx5bHJUZyVLuT7+anW55GMM4=
In-Reply-To: <uc0sfl$23foj$1@dont-email.me>
Content-Language: en-US
 by: Dmitry A. Kazakov - Tue, 22 Aug 2023 07:38 UTC

On 2023-08-22 01:37, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:ubsmak$1a024$1@dont-email.me...
> ...
>> Of course it must be generic, which kills all fun.
>
> As noted in my other message, resurrecting the Ada 95 idea allowing
> class-wide types for elementary types would eliminate (or at least greatly
> reduce) this problem.

Yes, but that would be a huge change.

> I think that would be a more productive way to address
> this problem than hacking around with 'Image some more. (We've already
> proven that it is not a good way to define anything user-defined, thus the
> rather complex way to define such 'Image attributes.)

One does not exclude another. If you allowed classes then there would be
no reason not to have attributes official primitive operations. E.g. an
"imaginable" interface would provide "'Image" and the standard Integer
would inherit to "imaginable"...

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Parameterised 'Image Attributes

<uc1qnq$2anmi$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9953&group=comp.lang.ada#9953

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Tue, 22 Aug 2023 10:13:47 +0200
Organization: A noiseless patient Spider
Lines: 127
Message-ID: <uc1qnq$2anmi$2@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me> <kkca55F9sn7U1@mid.individual.net>
<ubsf4e$19bvo$1@dont-email.me> <ubsn75$1a024$2@dont-email.me>
<uc0sae$23f5l$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 22 Aug 2023 08:13:46 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="68fb8d4c60f45eceaa1fe84bc52eb712";
logging-data="2449106"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18bgZkrY8JQ1Byjxi8dDBEYK9EjE0/oI1I="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:b/yI8DAHslXkGDGe44fTOZiLv5g=
In-Reply-To: <uc0sae$23f5l$1@dont-email.me>
Content-Language: en-US
 by: Dmitry A. Kazakov - Tue, 22 Aug 2023 08:13 UTC

On 2023-08-22 01:34, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:ubsn75$1a024$2@dont-email.me...
>> On 2023-08-20 09:25, Randy Brukardt wrote:
>>
>>> Additionally, one ends up with a magic mechanism that only the compiler
>>> can
>>> use. That *never* is a good idea.
>>
>> A better idea would be to improve the language to remove need in magic,
>> but that is *never* a good idea either! (:-))
>
> No, I generally agree with this. We probably disagree on what would
> consistute an improvement, however. ;-)

To the same effect...

>>> Attributes do not allow named parameters outside a few special cases, and
>>> *never* allow reordering of parameters. Does that need to change, too?
>>
>> Elementary! Attribute is just an alternative syntactic form of a
>> subroutine call. There is no reason why attribute should be limited to
>> look like FORTRAN IV! (:-))
>
> That turns out to be a bad idea. The reason people love attributes so is
> that they don't have to worry about visibility -- they're always visible.
> That is not and cannot be true for subprograms.
>
> For example, the reason that we don't allow user-defined attributes is that
> they would compromise portability. Since they're always visible, they could
> hide/make illegal attributes that are used in units (like generic units)
> that don't know anything about the additions.

In other words attribute is a primitive subprogram, yes.

> Moreover, not all attributes
> can be described as subprograms given Ada's current rules (reduction
> attributes have a type parameter; some of the annex 13 attributes have "any
> type" parameters, etc.)

It is a primitive subprogram of some built-in class. The magic is not in
the attribute, it is the class description. For magical classes
overriding a primitive operation could look like

for <member-type>'<primitive-operation-name> use <subroutine-name>;

> It certainly would be a very bad thing for Janus/Ada, which would have to
> have its resolution and subprogram definition mechanisms redesigned. (All
> subprograms are materialized in the Janus/Ada symboltable, in particular for
> visibility management reasons, and that would not be possible for
> attributes. Resolution only works on materialized subprogram definitions.)

Only if you wanted to remove all magic, which is never be possible. But
you can do some.

>>> 'Image is convinient for integer and enumeration output, and one can
>>> format
>>> them in the rare case where that is necessary. But it is useless for
>>> float
>>> output -- manual reformatting the output of 'Image would round the
>>> results
>>> incorrectly.
>>
>> Which is why Float 'Image must have parameters!
>
> Which is why one shouldn't use Float'Image! ;-)

Any application programmer will tell you that all types must have
'Image! (:-))

>>> Ada has few built-in facilities because it's primary purpose is to
>>> support
>>> the development of proper ADTs. Ease of writing is not a goal at all, and
>>> in
>>> most cases, the extra text is valuable to compilers and tools (even if it
>>> is
>>> not so valuable to human readers).
>>
>> How is this related to attribute 'Image lacking necessary parameters? Why
>> generic function having such parameters is OK, while 'Image with same
>> parameters is not?
>
> It's perfectly OK to overload functions however one wants, because you can
> keep anything that is problem from being considered by avoiding "use" (and
> "with").
>
> 'Image is not appropriate for an attribute in the first place; attributes
> are supposed to be simple compile-time defined properties of a type. String
> conversion is not that.

But stream serialization is?

The problem is that whatever intention Ada designers had for attributes
they also gave them property of being a primitive operation where no
user-defined class allowed. This power steamrolls any "good" intentions.

Nobody loves the syntax T'Image (X) or X'Image! Give programmers X.Image
and [<path-of-package-names-nobody-remembers>].Image (X) and they will
forget about the attribute.

> My preference for making Ada easier to use for this sort of thing is allow
> class-wide elementary types. Then one could have non-generic subnprograms
> that operation on all integer and float types.

Yes.

> (Fixed and enumerations would
> still require generics, although I suspect most people would simply convert
> fixed to float for output rather than worrying about an instantiation.)

It would be interesting to play with the ways of constructing
enumeration and fixed point classes. Both have static parameters, e.g.
list of names in the case of enumeration. There might be a way achieve
static polyphormism without going full generic but also without turning
the language into a C++ templates mess!

> That
> would make a library simple to use, and few people would think that
> something builr-in is needed.

Absolutely. Ideally, everything must go into libraries.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Parameterised 'Image Attributes

<4c861cba-9ad6-429d-b530-a40c45dfc176n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9955&group=comp.lang.ada#9955

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:620a:1a92:b0:76d:8460:70e9 with SMTP id bl18-20020a05620a1a9200b0076d846070e9mr133949qkb.7.1692786007935;
Wed, 23 Aug 2023 03:20:07 -0700 (PDT)
X-Received: by 2002:a17:903:1c4:b0:1bc:7c69:925c with SMTP id
e4-20020a17090301c400b001bc7c69925cmr5470038plh.10.1692786007660; Wed, 23 Aug
2023 03:20:07 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 23 Aug 2023 03:20:07 -0700 (PDT)
In-Reply-To: <uc1qnq$2anmi$2@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=205.239.40.3; posting-account=YRfoYAoAAADhSEO2nLYx10QUUvp8akYl
NNTP-Posting-Host: 205.239.40.3
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me> <kkca55F9sn7U1@mid.individual.net>
<ubsf4e$19bvo$1@dont-email.me> <ubsn75$1a024$2@dont-email.me>
<uc0sae$23f5l$1@dont-email.me> <uc1qnq$2anmi$2@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4c861cba-9ad6-429d-b530-a40c45dfc176n@googlegroups.com>
Subject: Re: Parameterised 'Image Attributes
From: joviangm@gmail.com (Stephen Davies)
Injection-Date: Wed, 23 Aug 2023 10:20:07 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2091
 by: Stephen Davies - Wed, 23 Aug 2023 10:20 UTC

On Tuesday, 22 August 2023 at 09:13:50 UTC+1, Dmitry A. Kazakov wrote:
> Nobody loves the syntax T'Image (X) or X'Image! Give programmers X.Image
> and [<path-of-package-names-nobody-remembers>].Image (X) and they will
> forget about the attribute.

I have no issue with the 'Image syntax.

Perhaps the formatting parameters could be restricted to T'Image(X) and
not available for X'Image? Or, maybe the language should just add
'Trim_Image and 'Trim_Width and leave the advanced formatting to a
library.

Actually, I think it might also be nice if Float'Trim_Image(X) returned
a string that only used exponential notation for very large or very
small values (which seems to be the default behaviour in Python).
Different names would then be needed (Tidy_Image and Tidy_Width?).

Re: Parameterised 'Image Attributes

<uc5bc8$3072a$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9956&group=comp.lang.ada#9956

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Wed, 23 Aug 2023 18:16:10 +0200
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <uc5bc8$3072a$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me> <kkca55F9sn7U1@mid.individual.net>
<ubsf4e$19bvo$1@dont-email.me> <ubsn75$1a024$2@dont-email.me>
<uc0sae$23f5l$1@dont-email.me> <uc1qnq$2anmi$2@dont-email.me>
<4c861cba-9ad6-429d-b530-a40c45dfc176n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 23 Aug 2023 16:16:08 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5d2fc566cdd20e6ee964b2d9b0417ccc";
logging-data="3152970"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+6TBIEkT+Yf2B6GmM84le+cPN7TYY6sp8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:F8RbZNlhm55HAqWG3MtBpFusB3o=
Content-Language: en-US
In-Reply-To: <4c861cba-9ad6-429d-b530-a40c45dfc176n@googlegroups.com>
 by: Dmitry A. Kazakov - Wed, 23 Aug 2023 16:16 UTC

On 2023-08-23 12:20, Stephen Davies wrote:

> Actually, I think it might also be nice if Float'Trim_Image(X) returned
> a string that only used exponential notation for very large or very
> small values (which seems to be the default behaviour in Python).

To use the shortest representation for the given precision unless
specified otherwise:

http://www.dmitry-kazakov.de/ada/strings_edit.htm#6

Ada 'Image attributes have "typographic quality" in plain contradiction
to the claim being for debugging purpose. That is why the plus sign is
always represented by a space and why floating-point representation is
always selected even for exact zero and the way the exponent part is
formatted. The typographic idea is to have *same looking* output. Note,
even if the output is mathematically incorrect as in the case of
floating-point numbers. 'Image considers precision and accuracy same,
which is *always* wrong when dealing with floating-point numbers.

> Different names would then be needed (Tidy_Image and Tidy_Width?).

It takes several parameters to control the behavior in a reasonable way.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Parameterised 'Image Attributes

<d75e72ad-0f5b-49c3-8cbf-630136a8a7a5n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9957&group=comp.lang.ada#9957

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:7f07:0:b0:40f:f509:3a75 with SMTP id f7-20020ac87f07000000b0040ff5093a75mr200785qtk.7.1692907178048;
Thu, 24 Aug 2023 12:59:38 -0700 (PDT)
X-Received: by 2002:a81:b64e:0:b0:589:a3d6:2e02 with SMTP id
h14-20020a81b64e000000b00589a3d62e02mr366689ywk.3.1692907177668; Thu, 24 Aug
2023 12:59:37 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Thu, 24 Aug 2023 12:59:37 -0700 (PDT)
In-Reply-To: <uc5bc8$3072a$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a02:c7e:270d:5200:f8:67c1:56b5:a609;
posting-account=YRfoYAoAAADhSEO2nLYx10QUUvp8akYl
NNTP-Posting-Host: 2a02:c7e:270d:5200:f8:67c1:56b5:a609
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me> <kkca55F9sn7U1@mid.individual.net>
<ubsf4e$19bvo$1@dont-email.me> <ubsn75$1a024$2@dont-email.me>
<uc0sae$23f5l$1@dont-email.me> <uc1qnq$2anmi$2@dont-email.me>
<4c861cba-9ad6-429d-b530-a40c45dfc176n@googlegroups.com> <uc5bc8$3072a$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d75e72ad-0f5b-49c3-8cbf-630136a8a7a5n@googlegroups.com>
Subject: Re: Parameterised 'Image Attributes
From: joviangm@gmail.com (Stephen Davies)
Injection-Date: Thu, 24 Aug 2023 19:59:38 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3016
 by: Stephen Davies - Thu, 24 Aug 2023 19:59 UTC

On Wednesday, 23 August 2023 at 17:16:12 UTC+1, Dmitry A. Kazakov wrote:
> On 2023-08-23 12:20, Stephen Davies wrote:
>
> > Actually, I think it might also be nice if Float'Trim_Image(X) returned
> > a string that only used exponential notation for very large or very
> > small values (which seems to be the default behaviour in Python).
> To use the shortest representation for the given precision unless
> specified otherwise:
>
> http://www.dmitry-kazakov.de/ada/strings_edit.htm#6
>
> Ada 'Image attributes have "typographic quality" in plain contradiction
> to the claim being for debugging purpose. That is why the plus sign is
> always represented by a space and why floating-point representation is
> always selected even for exact zero and the way the exponent part is
> formatted. The typographic idea is to have *same looking* output. Note,
> even if the output is mathematically incorrect as in the case of
> floating-point numbers. 'Image considers precision and accuracy same,
> which is *always* wrong when dealing with floating-point numbers.
> > Different names would then be needed (Tidy_Image and Tidy_Width?).
> It takes several parameters to control the behavior in a reasonable way.
> --
How about an attribute called something like User_Image
where programmers should make no assumption about the
generated strings and implementations can provide
OS-specific ways to customise things like leading
space/plus/neither, decimal separator character, digit
grouping character/spacing, exponential notation, enum
casing, etc.

Re: Parameterised 'Image Attributes

<uc9l2b$3u0pe$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9961&group=comp.lang.ada#9961

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Fri, 25 Aug 2023 09:26:07 +0200
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <uc9l2b$3u0pe$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me> <kkca55F9sn7U1@mid.individual.net>
<ubsf4e$19bvo$1@dont-email.me> <ubsn75$1a024$2@dont-email.me>
<uc0sae$23f5l$1@dont-email.me> <uc1qnq$2anmi$2@dont-email.me>
<4c861cba-9ad6-429d-b530-a40c45dfc176n@googlegroups.com>
<uc5bc8$3072a$1@dont-email.me>
<d75e72ad-0f5b-49c3-8cbf-630136a8a7a5n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 25 Aug 2023 07:26:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="38d7616789a656b231dda5c462d4acb3";
logging-data="4129582"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19rB1oOp9CzuT4SIOA2j1rocKOXHiBhu2M="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:4YqVOnKWokgkqmpUNKUHAonjlaU=
Content-Language: en-US
In-Reply-To: <d75e72ad-0f5b-49c3-8cbf-630136a8a7a5n@googlegroups.com>
 by: Dmitry A. Kazakov - Fri, 25 Aug 2023 07:26 UTC

On 2023-08-24 21:59, Stephen Davies wrote:
> On Wednesday, 23 August 2023 at 17:16:12 UTC+1, Dmitry A. Kazakov wrote:
>> On 2023-08-23 12:20, Stephen Davies wrote:
>>
>>> Actually, I think it might also be nice if Float'Trim_Image(X) returned
>>> a string that only used exponential notation for very large or very
>>> small values (which seems to be the default behaviour in Python).
>> To use the shortest representation for the given precision unless
>> specified otherwise:
>>
>> http://www.dmitry-kazakov.de/ada/strings_edit.htm#6
>>
>> Ada 'Image attributes have "typographic quality" in plain contradiction
>> to the claim being for debugging purpose. That is why the plus sign is
>> always represented by a space and why floating-point representation is
>> always selected even for exact zero and the way the exponent part is
>> formatted. The typographic idea is to have *same looking* output. Note,
>> even if the output is mathematically incorrect as in the case of
>> floating-point numbers. 'Image considers precision and accuracy same,
>> which is *always* wrong when dealing with floating-point numbers.
>>> Different names would then be needed (Tidy_Image and Tidy_Width?).
>> It takes several parameters to control the behavior in a reasonable way.
>> --
> How about an attribute called something like User_Image
> where programmers should make no assumption about the
> generated strings and implementations can provide
> OS-specific ways to customise things like leading
> space/plus/neither, decimal separator character, digit
> grouping character/spacing, exponential notation, enum
> casing, etc.

How anything can be implemented without making assumptions = specifications?

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Parameterised 'Image Attributes

<41ae24fb-793e-4bb7-9086-c8923ddc5d9dn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9962&group=comp.lang.ada#9962

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ad4:4f4d:0:b0:649:e869:ec71 with SMTP id eu13-20020ad44f4d000000b00649e869ec71mr392982qvb.1.1692954281554;
Fri, 25 Aug 2023 02:04:41 -0700 (PDT)
X-Received: by 2002:a25:e757:0:b0:d0b:c67:de3b with SMTP id
e84-20020a25e757000000b00d0b0c67de3bmr387085ybh.13.1692954281305; Fri, 25 Aug
2023 02:04:41 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Fri, 25 Aug 2023 02:04:41 -0700 (PDT)
In-Reply-To: <uc9l2b$3u0pe$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=205.239.40.3; posting-account=YRfoYAoAAADhSEO2nLYx10QUUvp8akYl
NNTP-Posting-Host: 205.239.40.3
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me> <kkca55F9sn7U1@mid.individual.net>
<ubsf4e$19bvo$1@dont-email.me> <ubsn75$1a024$2@dont-email.me>
<uc0sae$23f5l$1@dont-email.me> <uc1qnq$2anmi$2@dont-email.me>
<4c861cba-9ad6-429d-b530-a40c45dfc176n@googlegroups.com> <uc5bc8$3072a$1@dont-email.me>
<d75e72ad-0f5b-49c3-8cbf-630136a8a7a5n@googlegroups.com> <uc9l2b$3u0pe$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <41ae24fb-793e-4bb7-9086-c8923ddc5d9dn@googlegroups.com>
Subject: Re: Parameterised 'Image Attributes
From: joviangm@gmail.com (Stephen Davies)
Injection-Date: Fri, 25 Aug 2023 09:04:41 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Stephen Davies - Fri, 25 Aug 2023 09:04 UTC

On Friday, 25 August 2023 at 08:26:08 UTC+1, Dmitry A. Kazakov wrote:
> On 2023-08-24 21:59, Stephen Davies wrote:
> > How about an attribute called something like User_Image
> > where programmers should make no assumption about the
> > generated strings and implementations can provide
> > OS-specific ways to customise things like leading
> > space/plus/neither, decimal separator character, digit
> > grouping character/spacing, exponential notation, enum
> > casing, etc.
> How anything can be implemented without making assumptions = specifications?
The reason that the existing 'Image cannot be changed is that it would
break existing software that replies upon knowledge about the generated
string, e.g. Integer'Image(Year)(2..5).
So the programmer could use 'User_Image to generate a display string
that will be formatted to the users preferences without knowing
(or being able to make assumptions about) those preferences,
e.g. Put_Line ("The result is " & Result'User_Image)

Re: Parameterised 'Image Attributes

<uca8pu$1lse$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9963&group=comp.lang.ada#9963

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Parameterised 'Image Attributes
Date: Fri, 25 Aug 2023 15:02:58 +0200
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <uca8pu$1lse$1@dont-email.me>
References: <ubn5un$5tvt$1@dont-email.me> <ubn9u8$6fup$1@dont-email.me>
<ubq15l$oa8i$1@dont-email.me> <kkca55F9sn7U1@mid.individual.net>
<ubsf4e$19bvo$1@dont-email.me> <ubsn75$1a024$2@dont-email.me>
<uc0sae$23f5l$1@dont-email.me> <uc1qnq$2anmi$2@dont-email.me>
<4c861cba-9ad6-429d-b530-a40c45dfc176n@googlegroups.com>
<uc5bc8$3072a$1@dont-email.me>
<d75e72ad-0f5b-49c3-8cbf-630136a8a7a5n@googlegroups.com>
<uc9l2b$3u0pe$1@dont-email.me>
<41ae24fb-793e-4bb7-9086-c8923ddc5d9dn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 25 Aug 2023 13:02:54 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="38d7616789a656b231dda5c462d4acb3";
logging-data="55182"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+qWYDmSin0QhkZglSL89dhWxX89qn83rA="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.14.0
Cancel-Lock: sha1:QE3+LQyfbZZ+W1gVDkQKIyiscEI=
In-Reply-To: <41ae24fb-793e-4bb7-9086-c8923ddc5d9dn@googlegroups.com>
Content-Language: en-US
 by: Dmitry A. Kazakov - Fri, 25 Aug 2023 13:02 UTC

On 2023-08-25 11:04, Stephen Davies wrote:
> On Friday, 25 August 2023 at 08:26:08 UTC+1, Dmitry A. Kazakov wrote:
>> On 2023-08-24 21:59, Stephen Davies wrote:
>>> How about an attribute called something like User_Image
>>> where programmers should make no assumption about the
>>> generated strings and implementations can provide
>>> OS-specific ways to customise things like leading
>>> space/plus/neither, decimal separator character, digit
>>> grouping character/spacing, exponential notation, enum
>>> casing, etc.
>> How anything can be implemented without making assumptions = specifications?
> The reason that the existing 'Image cannot be changed is that it would
> break existing software that replies upon knowledge about the generated
> string, e.g. Integer'Image(Year)(2..5).

The proposal was to add parameters defaulted to the existing behavior.

Year'Image (Plus=>None,Width=>4,Alignment=>Right,Padding=>'0')

> So the programmer could use 'User_Image to generate a display string
> that will be formatted to the users preferences without knowing
> (or being able to make assumptions about) those preferences,
> e.g. Put_Line ("The result is " & Result'User_Image)

This will be rejected on the same grounds as the original proposal. Read
Randy's response.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor