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-7-bit Path: g2news1.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Newbie question Date: Thu, 12 Mar 2009 11:07:00 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <49b90e2d$0$2847$ba620e4c@news.skynet.be> <0ff2f139-06cf-4fa5-8c0d-f97c43a33186@s20g2000yqh.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1236870421 26032 192.74.137.71 (12 Mar 2009 15:07:01 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 12 Mar 2009 15:07:01 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:f/7r4btTQunnCtV/Csiaz73dgUE= Xref: g2news1.google.com comp.lang.ada:4078 Date: 2009-03-12T11:07:00-04:00 List-Id: Ludovic Brenta writes: > Solution 3: introduce a new value for Piece_Type_T: > > type Piece_Type_T is (None, Pawn, Knight, Bishop, Rook, Queen, King); > > I don't know which is the best solution; perhaps you'd like to try > them all and see how well they integrate with the algorithms. I think > Solution 3 is the most error-prone, though. A variation on 3 is not error prone: type Optional_Piece_Kind is (None, Pawn, Knight, Bishop, Rook, Queen, King); subtype Piece_Kind is Optional_Piece_Kind range Optional_Piece_Kind'Succ(None)..Optional_Piece_Kind'Last; type Square(Kind: Optional_Piece_Kind is := None) is record case Kind is when None => null; when Piece_Kind => Color: ...; end case; end record; type Rank is range 1..8; type File is new Character range 'A'..'H'; -- Maybe I've got this backwards??? type Board is array (Rank, File) of Square; As somebody said, you will want a default value for the discriminant, in all these variations. Having a default has the odd property that it allows you to change the discriminant by a whole-record assignment. This oddity often confuses beginners to Ada. - Bob