From: Wannabe h4x0r <chris@dont.spam.me>
Subject: Re: Case statement and Integers.
Date: Sun, 21 Apr 2002 03:59:47 GMT
Date: 2002-04-21T03:59:47+00:00 [thread overview]
Message-ID: <SOqw8.83292$G72.59381@sccrnsc01> (raw)
In-Reply-To: Itiw8.3026$dk4.1626810405@newssvr14.news.prodigy.com
On Sat, 20 Apr 2002 14:31:04 -0400, tmoran wrote:
> 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.
>
This technique works but ...
>> 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.
... your point is well taken. I suppose I do have a tendency to go
overboard.
I'll keep your technique in mind, but will for the time being defer to
the if...then...else method of doing the sort.
Thanks
Chris
next prev parent reply other threads:[~2002-04-21 3:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-20 16:42 Case statement and Integers Wannabe h4x0r
2002-04-20 17:04 ` Rhoady
2002-04-20 17:11 ` Alan Reynolds
2002-04-20 17:32 ` Wannabe h4x0r
2002-04-20 18:31 ` tmoran
2002-04-21 3:59 ` Wannabe h4x0r [this message]
2002-04-22 3:01 ` Robert Dewar
2002-04-22 5:14 ` Anders Wirzenius
2002-04-20 21:26 ` Ted Dennison
2002-04-20 19:14 ` Vadim Godunko
2002-04-22 3:05 ` Robert Dewar
2002-04-22 8:41 ` Vadim Godunko
2002-04-22 13:16 ` Robert Dewar
2002-04-23 6:38 ` Wannabe h4x0r
2002-04-22 16:58 ` Anatoly Chernyshev
2002-04-22 17:55 ` tmoran
2002-04-22 19:51 ` Anatoly Chernyshev
2002-04-24 11:41 ` Robert Dewar
-- strict thread matches above, loose matches on Subject: below --
2002-04-22 9:11 Grein, Christoph
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox