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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1c1a139977eee854 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-04-20 11:32:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!207.115.63.138!newscon04.news.prodigy.com!newsmst01.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr14.news.prodigy.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Case statement and Integers. References: X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 67.115.105.248 X-Complaints-To: abuse@prodigy.net X-Trace: newssvr14.news.prodigy.com 1019327464 ST000 67.115.105.248 (Sat, 20 Apr 2002 14:31:04 EDT) NNTP-Posting-Date: Sat, 20 Apr 2002 14:31:04 EDT Organization: Prodigy Internet http://www.prodigy.com X-UserInfo1: Q[O[SX[DGJVOBFD[LZKJOPHAWB\^PBQLGPQRJWQHBATBTSUBYFWEAE[YJLYPIWKHTFCMZKVMB^[Z^DOBRVVMOSPFHNSYXVDIE@X\BUC@GTSX@DL^GKFFHQCCE\G[JJBMYDYIJCZM@AY]GNGPJD]YNNW\GSX^GSCKHA[]@CCB\[@LATPD\L@J\\PF]VR[QPJN Date: Sat, 20 Apr 2002 18:31:04 GMT Xref: archiver1.google.com comp.lang.ada:22827 Date: 2002-04-20T18:31:04+00:00 List-Id: > case numbers(j) is > when numbers(j) < pivot => swap(left_swap, right_swap); > when numbers(j) > pivot => swap(right_swap, left_swap); > when numbers(j) = pivot => null; > when others => null; The items after the "when" must be constant values of "numbers(j)". This code has dynamic boolean expressions. "case" is not just another syntax for "if then". When the compiler sees a "case" statement it should, at least conceptually if not in implementation, be able to create a jump table indexed by the value of "numbers(j)". It clearly can't do that here. If you had a comparison function type Compare_Results is (LT, EQ, GT); function Compare(Left, Right : Numbers_Type) return Compare_Results; then you could say case Compare(numbers(j), pivot) is when LT => when GT => when EQ => end case; because the compiler could create a three-entry jump table. > Using an if..else statement wouldn't be original. Bicycling to Hawaii is original - but it won't work either. In Software Engineering, the point is to make something that works, not necessarily something original. In fact, since you will abandon most of your code to your maintenance successors (one hopes you move on to new things!), and originality will just confuse them, originality itself is a downright *negative* aspect of code, to be used only when the negative is outweighed by the positive benefits of the novel technique.