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: Wed, 16 Dec 2020 18:53:06 -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> <570e9d30-0b33-45f0-a9fe-163cc810a770n@googlegroups.com> Injection-Date: Thu, 17 Dec 2020 00:53:08 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="29579"; 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; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:60873 List-Id: "AdaMagica" wrote in message news:a75e5fc2-8393-4c2b-85b9-7c3b4cfef85dn@googlegroups.com... > Simon Wright schrieb am Dienstag, 15. Dezember 2020 um 17:54:01 UTC+1: >> I suppose the compiler could still detect & warn about inadvertent use >> of the don't-care value. > Just a story about my work (long ago): > Our coding standard required for every type declaration a default value > that indicated an uninitialised value: > > type T is ... > Nd_T: constant T := ...; -- Nd: not defined > X: T := Nd_T; -- required > > The idea was that this Nd value should be thus that it would be likely to > produce an exception when used in an expression. Also any change of this > value should have absolutely no effect on the code. > In any case, at some time it was decided that the Nd value for numeric > types was 0. The effect: > It was no longer possible to see whether in a declaration like > X: T := Nd_T; > this values denoted a truly undefined value or a concrete and correct > initial value. Typically, values like this, at least those used in debuggers, use some premutation of 16#DEADBEEF# since it it obvious in data dumps, and is a rather unlikely value to be intended. The next version of Janus/Ada will initialize all "uninitialized" objects to this value unless you tell it not to. (Essentially, a version of Normalize_Scalars, except that these days it doesn't make much sense for that not to be the default. Optimization can remove most of unneeded initializations, and if they are actually needed, it's better to have a known dubious value than stack garbage.) Randy.