From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Possible to recover default value of scalar type? Date: Mon, 14 Dec 2020 19:26:10 -0600 Organization: JSA Research & Innovation Message-ID: References: <0c0ddb8e-6a82-473d-8143-f4076242f520n@googlegroups.com> <86r1ntntb3.fsf@stephe-leake.org> <0ded905f-94ac-4470-936c-7f1cb19ac798n@googlegroups.com> <82e629ea-bd59-417a-9185-dd6094e396c1n@googlegroups.com> Injection-Date: Tue, 15 Dec 2020 01:26:11 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="21240"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:60853 List-Id: "Dmitry A. Kazakov" wrote in message news:rr7bqv$19da$1@gioia.aioe.org... > 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) I would have suggested to write this as: procedure Library_Foo (Bar : Baz := <>) since this is the syntax used in aggregates (and why should aggregates have all the fun??). > Put_Line (String (1..10)'Default_Value); -- print garbage The above isn't a legal attribute prefix in any case (can't slice a type). And you don't need to because this is clearly an aggregate (which is legal in Ada 2012): Put_Line (String'(1..10 => <>)); -- print garbage Randy.