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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b1208117d36fb121 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-04-12 13:20:27 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: dewar@gnat.com (Robert Dewar) Newsgroups: comp.lang.ada Subject: Re: System.Address'Size - not a static integer expression? Date: 12 Apr 2002 13:20:27 -0700 Organization: http://groups.google.com/ Message-ID: <5ee5b646.0204121220.606ecc36@posting.google.com> References: <665e587a.0203060957.3682edf7@posting.google.com> <5ee5b646.0203061721.36d42541@posting.google.com> <3C877185.1CF93423@despammed.com> <7f1fa3aa.0203081034.12a7bd11@posting.google.com> <3C891463.C4C09795@despammed.com> <5ee5b646.0204072057.48d33742@posting.google.com> <3CB1B473.CF6E93AD@despammed.com> <5ee5b646.0204091754.5dcfd16d@posting.google.com> <3CB47947.466E0E81@despammed.com> NNTP-Posting-Host: 205.232.38.14 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1018642827 859 127.0.0.1 (12 Apr 2002 20:20:27 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 12 Apr 2002 20:20:27 GMT Xref: archiver1.google.com comp.lang.ada:22446 Date: 2002-04-12T20:20:27+00:00 List-Id: Wes Groleau wrote in message news:<3CB47947.466E0E81@despammed.com>... > Static to me (before Ada 95) meant a value that you can > determine at compile time. The RM apparently has a > different meaning when it disallowed > for xxx'size use .... (A) > because 'size is not static The term static is a technical term in both Ada 83 and Ada 95 that refers to *subset* of expressions whose value an be determined at compile time. Obviously the predicate "can determine at compile time" is recursively undecidable, so you can't really mean what you said above, and in any case it is just wrong. There are plenty of expressions whose value can obviously be determined at compile time which are definitely NOT static. For example, if we write s,t : float := ... type f is new float range s .. t; then the expression f'digits is not static, even though it is obvious that has the same value as float'digits, which *is* static. Why? Because attributes are static only if applied to a static scalar subtype, which f is obviously NOT (this rule is identical in Ada 83 and Ada 95). Could the rule have been written to allow this particular expression? Sure, but the point is that the boundary is going to be arbitrary anyway, so it is easier to have a simple set of rules, even if they do rule out some cases which are obviously determinable at compile time. > The screwed up C definition of static is off in some > other planet. This comment is from left field, since the meaning of the keyword static in C is something completely and radically different that has nothing at all to do with the discussion at hand of static expressions in Ada. > What I was saying was that I tried to use xxx'size > somewhere that only static values were allowed and it was > rejected by both GNAT and Apex. Yes, because the expression was not static according to the 4.9 rules (of either RM!) > At the time, I considered the expression I used > static because it COULD BE determined at compile time. Fine, but that was a misunderstanding, static does NOT mean "COULD BE determined at compile time. > But I DID find something in the RM that said 'Size cannot > be used where a static expression is required. No you didn't, because there is no such rule. The actual rule is that 'Size is static if applied to a static scalar subtype, and otherwise is not static. But you won't find a rule in the RM that says that Size applied to a non-scalar type or a non-static scalar type is non-static. Why not? Because 4.9 is a list of rules for expressions that *are* static. All expressions not listed in these rules are implicitly non-static, without having to say so. > My point exactly: 'Size is not in this subset, no matter > how easy it may be to determine the value. You keep saying this, but it's wrong. Some 'Size references are static, Some are not, and the distinction is not whether they can be determined at compile time, it is whether the type involved is a non-static scalar type. > So you are saying that it IS in this subset > if the prefix is a static scalar subtype? Yes :-) several times > First, this is circular, defining static (partially) > in terms that use the word static. It is a perfectly sound recursive definition. There is no problem here, and I don't see why you are suggesting there might be. The definition of static scalar subtype is in RM 4.9(26) and seems clear enough. It is definitely the case that the definition of staticness is recursive. For example a+b is a static expression if a and b are static expressions. Nothing circular about that was of defining things! > Second, I can no longer remember whether it was a static > scalar subtype, but I do remember (1) the rejection > surprised me after years of Ada experience We can all be surprised by discovering something we did not know, but that does not make it wrong :-) > and (2) the reference _I_ > found for (A) above did not have the "static scalar > subtype" exception in it. It just plain said that 'Size > is not static. Well then this reference is (a) not in the RM, and (b) completely wrong. Nothing too surprising about that. Perhaps you read this on CLA :-) :-)