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.2 required=5.0 tests=BAYES_00,FROM_WORDY, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b50bc6538a649497 X-Google-Attributes: gid103376,public From: "Ken Garlington" Subject: Re: if statements Date: 2000/11/14 Message-ID: #1/1 X-Deja-AN: 693460079 References: X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Complaints-To: abuse@flash.net X-Trace: news.flash.net 974206800 216.215.65.106 (Tue, 14 Nov 2000 07:00:00 CST) Organization: FlashNet Communications, http://www.flash.net X-MSMail-Priority: Normal NNTP-Posting-Date: Tue, 14 Nov 2000 07:00:00 CST Newsgroups: comp.lang.ada Date: 2000-11-14T00:00:00+00:00 List-Id: "Duncan Sands" wrote in message news:E13vbW9-0000DP-00@Baldrick... : Here : is a code snippet using the Beer oriented methodology (which naturally : reflects the life style of many students) that swaps the values of two : integers A and B if A is the greater value. It uses an if statement. Well, this doesn't seem right. In particular: : type Beer is new Integer; -- this should be Natural; the -1 trick is no excuse (see below). : type Hand is (Left_Hand, Right_Hand); -- this should be type What_I_Call_My_Hands -- there should be a type Hand which is an access to Beer_Mug (see below) -- there should be a type Hands which is an array (What_I_Call_My_Hands) of Hand. : Mugs : array (Hand) of Beer_Mug; -- this should be two separate mugs, since a particular mug is not intrinsically tied to a particular Hand : type Table is record : Mug : Beer_Mug; : end record; -- clearly, Table should be an array (or set) of Beer_Mugs, since a Table could -- hold more than one Beer_Mug. : procedure Move_Mug (From, To : Hand) is : begin : if From = To or Mugs (From).Refreshing_Fluid = -1 then -- Ack! Arbitrary constants! Much better to allow a Hand to be set to null -- explicitly when it isn't accessing anything. -- Also, need to check that To is empty. : raise Tasking_Error; -- should really declare a new Drunken_Fool exception rather than using -- predefined exception