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,ca9eef4d5e2078ea X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Beware: Rep spec on an enumeration type causes code explosion Date: 1997/12/10 Message-ID: #1/1 X-Deja-AN: 296829816 References: X-Complaints-To: usenet@news.nyu.edu X-Trace: news.nyu.edu 881731017 11228 (None) 128.122.140.58 Organization: New York University Newsgroups: comp.lang.ada Date: 1997-12-10T00:00:00+00:00 List-Id: Tuck said <> Well things are not as bad as all that, and should be better :-) Loops need not generate significant inefficiency. Look back to the message I sent earlier showing how GNAT handles these loops. The overhead is a single indexed load per loop, not bad at all. Array indexes should NOT be a problem, if we used the rep value as an index instead of the pos value as an index. Unfortunately Verdix made what I think was the wrong implementation choice here, and the Ada 95 RM gives no recommendation, so in the absence of any RM advice, we find ourselves pushed to support Verdix compatibility, and thus introduce the unexpected inefficiency. To my mind, it would be better to index by default using the rep value, and if you want to index by the pos value, do so explicitly! Succ and Pred are indeed evil :-) <> No, I disagree, this is a useful feature that I have often found useful. You only get the inefficiencies if you use the inefficient constructs, and it seems unreasonable to argue that a feature should be removed because someone might use it inefficiently. I would say that if I had my choice, I would ban the use of Succ and Pred, and specify that array indexing was on the basis of pos values. That way the (relatively) expensive Pos operation would only occur if the programmer wrote it explicitly.