From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Advent of Code Day 7
Date: Tue, 8 Dec 2020 12:25:54 +0100 [thread overview]
Message-ID: <rqnns2$b1v$1@dont-email.me> (raw)
In-Reply-To: <df3d282a-ff8c-4fd7-befc-a6ca683215e1n@googlegroups.com>
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
next prev parent reply other threads:[~2020-12-08 11:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-07 23:03 Advent of Code Day 7 John Perry
2020-12-07 23:44 ` Randy Brukardt
2020-12-07 23:49 ` John Perry
2020-12-08 11:25 ` Jeffrey R. Carter [this message]
2020-12-08 16:55 ` John Perry
2020-12-08 23:25 ` Jeffrey R. Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox