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 X-Received: by 2002:a37:7007:: with SMTP id l7mr9650488qkc.353.1572600842856; Fri, 01 Nov 2019 02:34:02 -0700 (PDT) X-Received: by 2002:a9d:7545:: with SMTP id b5mr7502602otl.240.1572600842599; Fri, 01 Nov 2019 02:34:02 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!fdn.fr!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!j16no10065901qtl.0!news-out.google.com!p4ni208qtu.1!nntp.google.com!j16no10065890qtl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 1 Nov 2019 02:34:02 -0700 (PDT) In-Reply-To: <5dbbeda6$0$1458$e4fe514c@news.kpn.nl> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=136.163.208.2; posting-account=HFCrOQoAAABZD_f-UUbYHm3lJDIrh-UX NNTP-Posting-Host: 136.163.208.2 References: <5dbbeda6$0$1458$e4fe514c@news.kpn.nl> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <1a0b573e-11af-4e4c-9ccf-9a757ad8d970@googlegroups.com> Subject: Re: Anonymous array not allowed as components From: joakimds@kth.se Injection-Date: Fri, 01 Nov 2019 09:34:02 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:57407 Date: 2019-11-01T02:34:02-07:00 List-Id: Den fredag 1 november 2019 kl. 09:32:42 UTC+1 skrev L Dries: > I have an need for an array of Unbounded_Strings in which i define the=20 > elements. >=20 > I declared it as: >=20 > Debug_Proc : array (1 .. nr_Proc) of Unbounded_String :=3D > (Debug_Proc(Lan), > To_Unbounded_String("Only"), > To_Unbounded_String("Empty_Buffer"), > ... > etc. >=20 > Then I got the message: >=20 > 65:22 Anonymous array not allowed as components > This results i a position just before "array" >=20 > The value nr_Proc is defined in another package. > Debug_Proc(Lan) is an Unbounded String > I tried to replace nr_Proc by a value. The same result. > I tried to replave the value of the first Unbounded String by "--",=20 > again no result > I tried set it as an constant array, also no result. >=20 > What do I do wrong? > --=20 > L. Dries Hello L. Dries, Unbounded_String is well-known for being "slow" because it does unnecessary= heap-allocations. To avoid performance penalty the XString type has been d= efined in the GNATColl library. The point is that one should have very good= reasons to use Unbound_String in one's application and not use it needless= ly. In your case what you want is to map each integer in an interval to a speci= fic String. If that's the case I recommend taking advantage of expression f= unctions and case statements introduced in Ada 2012: type Index is new Integer range 1 .. nr_Proc; function Debug_Proc (I : Index) return String is (case I is when 1 =3D> "Only", when 2 =3D> "Empty_Buffer", ...); or maybe it is: function Debug_Proc (I : Index) return String is ((case I is when 1 =3D> "Only", when 2 =3D> "Empty_Buffer", ...)); The compiler will tell you. Best regards, Joakim