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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,243dc2fb696a49cd X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!news.glorb.com!news-stoc.telia.net!news-stoa.telia.net!telia.net!masternews.telia.net.!newsb.telia.net.POSTED!not-for-mail From: =?ISO-8859-1?Q?Bj=F6rn_Persson?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031114 X-Accept-Language: sv, sv-se, sv-fi, en-gb, en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl) References: <1ec946d1.0409230820.455ad242@posting.google.com> <3673998.bj16mkkOu2@linux1.krischik.com> <1700922.2nPlMsa4Ny@linux1.krischik.com> <1636756.M7hCqjsVMv@linux1.krischik.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Message-ID: Date: Fri, 01 Oct 2004 16:11:01 GMT NNTP-Posting-Host: 217.209.116.179 X-Complaints-To: abuse@telia.com X-Trace: newsb.telia.net 1096647061 217.209.116.179 (Fri, 01 Oct 2004 18:11:01 CEST) NNTP-Posting-Date: Fri, 01 Oct 2004 18:11:01 CEST Organization: Telia Internet Xref: g2news1.google.com comp.lang.ada:4515 Date: 2004-10-01T16:11:01+00:00 List-Id: Kevin Cline wrote: > Looks like I should have written: >=20 > struct X > { > int a; > int b; > float c; > std::string d; > } :-) I thought you'd counter with that. So now you have a structure with=20 two integers, a float and a string, and you need to set a variable such=20 that the one or the other integer is selected depending on the variable. = That makes it seem like there is some kind of relation between the=20 integers; a relation that isn't there with the float or the string. So=20 it seems natural to group the integers together: with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; procedure Demo is type AB_Index is (A, B); type AB_Type is array(AB_Index) of Integer; type X is record AB : AB_Type; C : Float; D : Unbounded_String; end record; X1 : X :=3D ((3, 5), 1.2, To_Unbounded_String("Apes")); X2 : X :=3D ((4, 6), 7.8, To_Unbounded_String("Beeps")); PTM : AB_Index :=3D A; begin pragma Assert(X1.AB(PTM) =3D 3); pragma Assert(X2.AB(PTM) =3D 4); PTM :=3D B; pragma Assert(X1.AB(PTM) =3D 5); pragma Assert(X2.AB(PTM) =3D 6); end Demo; --=20 Bj=F6rn Persson PGP key A88682FD omb jor ers @sv ge. r o.b n.p son eri nu