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: Advent of Code Day 7 Date: Mon, 7 Dec 2020 17:44:44 -0600 Organization: JSA Research & Innovation Message-ID: References: Injection-Date: Mon, 7 Dec 2020 23:44:46 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="1858"; 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:60758 List-Id: "John Perry" wrote in message news:df3d282a-ff8c-4fd7-befc-a6ca683215e1n@googlegroups.com... > When doing today's exercise, I encountered an issue where I wanted to > initialize only some fields of a record, with the other fields having a > default initialization. In particular: > > type Bag_Entry is record > Description: Bag_Description := " "; > Quantity: Positive; > end record; > > Entry: Bag_Entry := ( Quantity => 10 ); > > However, GNAT says this is invalid because I didn't specify > Bag_Description. I looked in the ARM but didn't see anyplace that implies > that; did I miss it? Is there a reason that Description can't be > initialized automatically according to the rules above? In Ada 2005 and later, write: Entry: Bag_Entry := (Quantity => 10, Description => <>); In an aggregate, <> means a default initialized component. Following the Ada Way TM ;-), one has to explicitly ask for a default initialized component -- just leaving it out might have been a mistake or intended -- neither the compiler nor a reader can tell. The above is clearly intended. Randy.