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: stt@henning.camb.inmet.com (Tucker Taft) Subject: Re: Side-effect arithmetic again [was: Ada ... in embedded systems] Date: 1996/03/29 Message-ID: #1/1 X-Deja-AN: 144859288 sender: news@inmet.camb.inmet.com (USENET news) x-nntp-posting-host: henning.camb.inmet.com references: organization: Intermetrics, Inc. newsgroups: comp.lang.ada Date: 1996-03-29T00:00:00+00:00 List-Id: Robert Dewar (dewar@cs.nyu.edu) wrote: : Robert/John/Tuck said : ": >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? : The 'Pos attribute returns a value of type universal_integer, : which is implicitly convertible to any integer type. Given that : you are adding it to a value of subtype Positive, it will be : converted to Integer (since Positive is a subtype of Integer). : See RM95 3.5.5(4), 8.6(24), 6.4.1(11)." : Sorry Tuck, I don't see this, I am adding two universal integer types here : seems clear to me that this addition is done in universal integer, i.e. : the longest possible integer type at runtime, and then converted to : Item type. Please enlighten me as to why you feel otherwise, I don't : see any "value of subtype Postive" in my expression! Oops! I was reading the original line of "Item'Pos(This) + By" instead of the suggested replacement. In the suggested replacement, where both operands are the result of 'Pos, the "preference" rule for root numeric types (8.6(14)) will mean that they will both be converted to root_integer, whose run-time base range is defined to be System.Min_Int .. System.Max_Int. See RM95 8.6(29) and 3.5.4(14). -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Cambridge, MA USA