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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c3a7c1845ec5caf9 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Equality operator overloading in ADA 83 Date: 1997/04/27 Message-ID: #1/1 X-Deja-AN: 237613415 References: <01bc4e9b$ac0e7fa0$72041dc2@lightning> <01bc5244$315f1560$28f982c1@xhv46.dial.pipex.com> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1997-04-27T00:00:00+00:00 List-Id: In article , Robert Dewar wrote: >What makes you thnk a compiler cannot as easily do this kind of optimization >for a series of comparisons against constant strings as it could for a >possibly extededn version of the case statement. Sure, an Ada compiler could do that. But none does (that I know of). That's not because it's infeasible. I think it has more to do with expectations. Nobody would expect that optimization, so nobody does it. And programmers who want to compare strings build hash tables, or whatever other technique they think is appropriate, by hand. They don't *expect* the compiler to do it for them. With a case statement, expectations are different. I certainly expect a jump table, when appropriate, rather than a series of compares. If case statements allowed strings, but still required static choices, I'm not sure what to expect -- but a series of elsifs certainly isn't the only reasonable choice. That was my point: when you have very high-level language features, you tend to lose the ability to guess what your compiler implementer is going to do, in terms of efficiency. Consider SETL, which has all kinds of fancy ways of implementing sets, versus Pascal, where the built-in set type is *expected* to be implemented as a bit string (although such things can never be *required*). - Bob