comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Possible to recover default value of scalar type?
Date: Mon, 14 Dec 2020 10:38:40 +0100	[thread overview]
Message-ID: <rr7bqv$19da$1@gioia.aioe.org> (raw)
In-Reply-To: 82e629ea-bd59-417a-9185-dd6094e396c1n@googlegroups.com

On 2020-12-14 10:01, AdaMagica wrote:
> I do not really understand the problem. It seems you want to be able to access the default value like so:
> N: Natural := Natural(A_Type'Default_Value);
> This is not possible. Thre is no corresponding attribute 'Default_Value.
> If this presents a real problem, submit it to Ada comment stating why this is important.

It could in the cases like this:

    procedure Library_Foo (Bar : Baz := Baz'Default_Value)

You can declare constants in some places, but not at the library level. 
But in any case, being forced to declare a constant each time you need 
to get at the default value?

The same problem arises with container generics. If you have an array 
keeping container elements, logically freed elements need to be 
"destroyed" in some way. The default type value would be that thing as 
well as a default for Null_Element, if used.

I think that all non-limited types one could declare uninitialized, must 
have S'Default_Value equal to the default value the compiler would use. 
And it should produce same warnings uninitialized values do:

    Put_Line (String (1..10)'Default_Value); -- print garbage

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

  reply	other threads:[~2020-12-14  9:38 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-13  9:54 Possible to recover default value of scalar type? reinert
2020-12-14  0:08 ` Stephen Leake
2020-12-14  6:09   ` reinert
2020-12-14  9:01     ` AdaMagica
2020-12-14  9:38       ` Dmitry A. Kazakov [this message]
2020-12-14 15:56         ` AdaMagica
2020-12-14 16:31           ` Dmitry A. Kazakov
2020-12-14 18:24             ` Simon Wright
2020-12-14 18:53               ` Dmitry A. Kazakov
2020-12-15  6:47                 ` J-P. Rosen
2020-12-15  7:23                   ` Dmitry A. Kazakov
2020-12-15  9:07                     ` J-P. Rosen
2020-12-15 16:53                       ` Simon Wright
2020-12-15 18:14                         ` AdaMagica
2020-12-17  0:53                           ` Randy Brukardt
2020-12-17  0:48                   ` Randy Brukardt
2020-12-15  1:27           ` Randy Brukardt
2020-12-15  9:30             ` Niklas Holsti
2020-12-17  0:45               ` Randy Brukardt
2020-12-15  1:26         ` Randy Brukardt
2020-12-15  7:35           ` Dmitry A. Kazakov
2020-12-17  0:43             ` Randy Brukardt
2020-12-15  1:21       ` Randy Brukardt
replies disabled

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