From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.stack.nl!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Quick question regarding limited type return syntax Date: Thu, 31 Jul 2014 21:12:41 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <166aaec5-5e9c-40e0-9b07-9b9c7d5f7f33@googlegroups.com> <16a6846f-2964-438a-ab9b-2029075f7924@googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1406859162 508 69.95.181.76 (1 Aug 2014 02:12:42 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 1 Aug 2014 02:12:42 +0000 (UTC) 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.6157 Xref: news.eternal-september.org comp.lang.ada:21368 Date: 2014-07-31T21:12:41-05:00 List-Id: "Adam Beneschan" wrote in message news:bf9193d6-e1a8-4df3-8e36-b07a2b07655e@googlegroups.com... ... >The effect is that subcomponents of Database that have default initial >values >will be initialized, and subcomponents that don't have default initial >values >will be initialized to garbage (except where the language says otherwise). >That's really the same as your original example was trying to do. I guess >that explicitly putting "others => <>" in an aggregate is enough to >convince GNAT not to think you were accidentally leaving something >initialized to garbage. I'd hope so: the syntax you gave says that you explicitly wanted something initialized to garbage. :-) [OK, explicitly default-initialized, whatever that does.] It's not a compiler's job to second-guess explicit instructions, programmers would get really annoyed if it did (and have a hard time getting anything done). It's annoying that we couldn't get this "explicit default-initialization" syntax more widely used. I prefer to ensure that everything is properly initialized, but sometimes the default value is good enough. It would be nice to be able to specify that: Obj : My_Type := <>; or maybe Obj : My_Type := (<>); so that I could verify that every object is either initialized or explicitly left default initialized. Right now, I use a comment: Obj : My_Type; -- Default initialize is OK here, because ... but it's hard for a tool to tell that everything is as it should be. (We tried to allow "(<>)" for private types for Ada 2005, but ran into a number of problems that eventually led us to give up. Too bad, I don't think they were insurmountable, but we were running short on time.) Randy.