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=0.6 required=5.0 tests=BAYES_00,FROM_WORDY 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 X-Google-ArrivalTime: 2000-11-07 21:29:36 PST Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!europa.netcrusader.net!128.230.129.106!news.maxwell.syr.edu!nntp.flash.net!news.flash.net!not-for-mail From: "Ken Garlington" Newsgroups: comp.lang.ada References: <3A02CED4.520C2768@brighton.ac.uk> <3A078B6F.D34B024B@erols.com> <8mTN5.7821$pq3.603668@news.flash.net> <3A0824BB.14ACCA12@bton.ac.uk> Subject: Re: if statements X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Message-ID: <4x5O5.8364$pq3.657453@news.flash.net> Date: Wed, 08 Nov 2000 05:29:36 GMT NNTP-Posting-Host: 216.215.83.96 X-Complaints-To: abuse@flash.net X-Trace: news.flash.net 973661376 216.215.83.96 (Tue, 07 Nov 2000 23:29:36 CST) NNTP-Posting-Date: Tue, 07 Nov 2000 23:29:36 CST Organization: FlashNet Communications, http://www.flash.net Xref: supernews.google.com comp.lang.ada:1875 Date: 2000-11-08T05:29:36+00:00 List-Id: "John English" wrote in message news:3A0824BB.14ACCA12@bton.ac.uk... : Ken Garlington wrote: : > Personally, I would have gone with something more along the lines of : > : > generic : > type Value is private; : > with function ">"(A, B : Value) return Boolean is <>; : > procedure Homework_Assignment(A, B : in out Value); : > : > -- Exchange is defined in the Ada Reference Manual : > with Exchange; : > procedure Homework_Assignment(A, B : in out Value) is : > procedure Swap is new Exchange(Value); : > begin : > if A > B then : > Swap(A,B); : > end if; : > end Homework_Assignment; : > : > Can't you imagine how pleased the instructor will be to find out that the : > student has already mastered generics? : : Unfortunately this sort of question gets marked by an automated : system, so the robotic instructor in question will, I'm afraid, : be deeply unimpressed. ;-) Would it mark it as correct? If the original question was "Exercise 4.1: Write an if statement which will swap the values of variables A and B if necessary so that the smaller value ends up in A and the larger value ends up in B." I actually think my solution is a more excruciatingly correct answer, compared to the "obvious" solution. In particular, the types of the variables are not specified, so the solution shouldn't assume one - right?