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,751584f55705ddb7 X-Google-Attributes: gid103376,public From: John G. Volan Subject: Re: Side-effect arithmetic again [was: Ada ... in embedded systems] Date: 1996/03/27 Message-ID: <4jcgk6$eeo@dayuc.dayton.saic.com>#1/1 X-Deja-AN: 144608915 distribution: world references: <4i6efq$dd9@dfw.dfw.net> <4j982l$cnh@usenet.srv.cis.pitt.edu> content-type: text/plain; charset=ISO-8859-1 x-xxmessage-id: organization: Science Applications International Corp. (SAIC) mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-03-27T00:00:00+00:00 List-Id: In article Robert Dewar, dewar@cs.nyu.edu writes: >John Volan said > >> procedure Increment (This : in out Item; By: in Positive) is >> begin >> This := Item'Val(Item'Pos(This) + By); >> end Increment; > >is that it doesn't just limit the "By" parameter to Standard.Positive, >it also limits the "This" parameter to possibly a relatively small >range of the Item type." > >Well I can't get particularly upset by that , but if you are, just >change this to Item'Val (Item'Pos(This) + Positive'Pos (By)). Okay, that leaves the exact type returned by the 'Pos functions ambiguous, but what does Ada95 do in that case? Does it just default to Standard.Integer anyway? (In that case, your answer doesn't really solve the problem.) Or can the compiler pick an integer type that's big enough? Or does this simply cause a compilation error? Anyway, I don't have much objection to this operation if it's limited to enumerated types, since the supported range of Standard.Integer on a given implementation is likely to correspond to the supported range of positions for an enumerated type on the same implementation. (Is the word "likely" correct, or does Ada95 provide a stronger guarantee of this?) But this operation is really of marginal utility for enumerated types anyway. And when applied to an integer or modular type, it's downright silly. Why would anyone want the second parameter to be Standard.Integer, when it could just be their own Item type, which is so much more simple and straightforward? In light of that, why do we need to keep propping up this 'Pos/'Val technique with ever more complicated encrustations? ------------------------------------------------------------------------ Internet.Usenet.Put_Signature ( Name => "John G. Volan", E_Mail => "John_Volan@dayton.saic.com", Favorite_Slogan => "Ada95: The *FIRST* International-Standard OOPL", Humorous_Disclaimer => "These opinions are undefined by SAIC, so" & "any use would be erroneous ... or is that a bounded error now?" ); ------------------------------------------------------------------------