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,e4042699db4db63b X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!41g2000yqf.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Newbie question Date: Thu, 12 Mar 2009 07:36:22 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <49b90e2d$0$2847$ba620e4c@news.skynet.be> <0ff2f139-06cf-4fa5-8c0d-f97c43a33186@s20g2000yqh.googlegroups.com> <49b9193a$0$2854$ba620e4c@news.skynet.be> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1236868583 5887 127.0.0.1 (12 Mar 2009 14:36:23 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 12 Mar 2009 14:36:23 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 41g2000yqf.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:4076 Date: 2009-03-12T07:36:22-07:00 List-Id: On Mar 12, 3:32=A0pm, stefan-lu...@see-the.signature wrote: > On Thu, 12 Mar 2009, Olivier Scalbert wrote: > > Ludovic Brenta wrote: > > > > Solution 2: merge the Boolean directly into Piece_T: > > > > type Piece_T (Present : Boolean) is record > > > =A0 =A0case Present is > > > =A0 =A0 =A0 when True =3D> > > > =A0 =A0 =A0 =A0 =A0Color : Color_T; > > > =A0 =A0 =A0 =A0 =A0Piece_Type : Piece_Type_T; > > > =A0 =A0 =A0 when False =3D> > > > =A0 =A0 =A0 =A0 =A0null; > > > =A0 =A0end case; > > > end record; > > Solution 2a: Use an enumeration: > > type Color_T is (Black, White, None); > > type Piece_T(Color: Color_T) is > =A0 record > =A0 =A0 case Color is > =A0 =A0 =A0 when White =3D> > =A0 =A0 =A0 =A0 White_Piece: Piece_Type_T; > =A0 =A0 =A0 when Black =3D> > =A0 =A0 =A0 =A0 Black_Piece: Piece_Type_T; > =A0 =A0 =A0 when None =3D> > =A0 =A0 =A0 =A0 null; > =A0 =A0 end case; > =A0 end record; The problem with this is that you'd then need two code paths for Black_Piece and White_Piece, every time. To overcome this, here is solution 2a1: type Square_T (Color : Color_T :=3D None) is record case Color is when None =3D> null; when Black | White =3D> Piece_Type : Piece_Type_T; end case; end record; -- Ludovic Brenta.