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/23 Message-ID: <4ivnr9$86o@dayuc.dayton.saic.com>#1/1 X-Deja-AN: 143854400 distribution: world references: <826571250.140@assen.demon.co.uk> <827432438.26126@assen.demon.co.uk> 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-23T00:00:00+00:00 List-Id: In article Robert I. Eachus, eachus@spectre.mitre.org writes: >In article <4iq2ia$lk7@dayuc.dayton.saic.com> >John G. Volan > writes: ... > (My conclusion was that you really only need one package:) ... > --add > > procedure Increment (This : in out Item; By: in Positive); > procedure Decrement (This : in out Item; By: in Positive); ... > procedure Increment (This : in out Item; By: in Positive) is ^^^^^^^^^ > begin > This := Item'Val(Item'Pos(This) + By); > end Increment; > > procedure Decrement (This : in out Item; By: in Positive) is ^^^^^^^^^ > begin > This := Item'Val(Item'Pos(This) - By); > end Decrement; ... Horrors! This assumes that Standard.Integer subsumes all possible ranges of 'Pos values for all discrete types (enumeration, integer, modular). A very dubious assumption! What about Long_Long_Integer? The long-term reusability of this package is problematic. Also, why limit Increment/Decrement to Positive? Why not allow any arbitrary integer? The C analogs for these procedures, += and -=, carry no such limitation. Finally, you're looking too narrowly at the problem: You seem to be focussed exclusively on analogs for ++ -- += -= , and are neglecting similarly contentious operations such as *= /= %= . Also, you're only looking at discrete types. What about real types? My inanely trivial packages covered all the bases. However, your Cycle operation is a nice touch. ------------------------------------------------------------------------ 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?" ); ------------------------------------------------------------------------