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,c7d533acec91ae16 X-Google-Attributes: gid103376,public From: Robert A Duff Subject: Re: Question for the folks who designed Ada95 Date: 1999/04/29 Message-ID: #1/1 X-Deja-AN: 472277050 Sender: bobduff@world.std.com (Robert A Duff) References: <7g2qu4$ca4$1@usenet.rational.com> <3725F4F1.7B615767@rocketmail.com> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1999-04-29T00:00:00+00:00 List-Id: Keith Thompson writes: > That's fine if the size of the shift is a constant, but as someone > else has pointed out, it's more difficult if it's a variable. I > suppose a compiler could optimize > > X := X * 2**N; > > to a shift instruction, but I'd hate to have to depend on it. I suppose in this variable case it's not so trivial as to be universally available, but it's still a feasible optimization (assuming the "2**" is sitting there for the compiler to see). One of our recently-validated compilers was in use for several months (and of course passed all of the validation tests) before we discovered a bug in our exponentiation run-time routine. Apparently, the vast majority of cases encountered in practise (and in the ACVC) where "**" is used are static expressions, and so were correctly calculated at compile time. This implies that if the above optimization isn't done, it's not commonly useful. Which also implies that variable-length shift operators are not commonly useful. > > It's not clear what shifting should mean if the modulus is not a power > > of 2. Robert has stated many times that that should never have been > > allowed, and I tend to agree. > > Do you mean that shifting should not be allowed for such types, or > that the types themselves should not be allowed? I meant that Robert strongly believes that the language should not allow non-power-of-two modular types. And I (weakly) agree. Actually, I have a lot of complaints about the modular type feature. Note that this feature was completely redesigned several times during the Ada 9X design. Sometimes I think the one we ended up with wasn't particularly *better* than the others, it just happened to be the one that was sitting there in the proposed standard document around the time when we were starting to freeze things (no more large technical changes). > If non-power-of-two modular types are really worth having in the > language, it might have been nice to make them a distinct class of > type, like decimal fixed-point vs. ordinary fixed-point. That would > allow providing shifts as attributes without running into generic > contract model problems. I think. At the expense of extra syntax and rules... - Bob -- Change robert to bob to get my real email address. Sorry.