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!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Advent of Code Day 7 Date: Tue, 8 Dec 2020 12:25:54 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 8 Dec 2020 11:25:54 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="3030b6eb4cf37069f3d0ce68eae32243"; logging-data="11327"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19/jaFFlqPJfedRXbyNRxYTn3wKKZZ0lk8=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 Cancel-Lock: sha1:YT230mGz123Cgt0V6hO/jIyNnDM= In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:60760 List-Id: On 12/8/20 12:03 AM, John Perry wrote: > > type Bag_Entry is record > Description: Bag_Description := " "; Humans are notoriously bad at counting things, and even worse at counting things they can't see, so this kind of literal can be a source of errors, especially during modification. (At least with Ada these tend to be compiler errors, not run-time errors.) Of course, Ada offers a Better Way. You can write Description: Bag_Description := (Bag_Description'range => ' '); or Description: Bag_Description := (others => ' '); and be proof against any changes to Bag_Description's bounds. I had a similar record, but I used Unbounded_String. -- Jeff Carter "Violence is the last refuge of the incompetent." Foundation 151