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 Path: g2news2.google.com!postnews.google.com!v23g2000pro.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: conversions between fixed-point types Date: Mon, 28 Sep 2009 08:15:17 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <4abc8389$1_1@glkas0286.greenlnk.net> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1254150917 5179 127.0.0.1 (28 Sep 2009 15:15:17 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 28 Sep 2009 15:15:17 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: v23g2000pro.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8515 Date: 2009-09-28T08:15:17-07:00 List-Id: On Sep 26, 7:43=A0am, Dirk Herrmann wrote: > Whom could I contact to figure out whether this is an omission in the lan= guage > definition (which could then be fixed) or whether it is intentional? =A0I= would > also like to ask about another issue: > > Dirk Herrmann wrote: > > =A0> Robert A Duff wrote: > =A0>> By the way, you can say: > =A0>> > =A0>> =A0 =A0 for T'Small use T'Delta; > =A0>> > =A0>> to avoid repeating yourself. > =A0> > =A0> I have tried that, especially since the very same recommendation was > =A0> given in the Barnes book "Ada 2005". =A0But, GNAT gives an error mes= sage. > =A0> It seems that the very moment you reference T'Delta the type T gets > =A0> "frozen" such that =A0the "use" statement itself freezes T before it= can > =A0> modify it. =A0I don't know if this is what the authors of the refere= nce > =A0> manual had intended, but GNAT interprets it that way. Although at first glance it seems like you should be able to do this, I don't think it's likely that the RM could make this work in the general case. The rules do say that the occurrence of T'Delta causes freezing; I believe this is part of the rule that an expression causes freezing (except for nonstatic expressions used in parameter or component defaults and some other cases). Here, T'Delta is a static expression and thus requires T to be frozen. If we were to make an exception that, say, a representation attribute of T does not cause freezing if it occurs in another representation clause for T, you could end up with some interesting situations: type Arr is array (1 .. 5) of Boolean; for A'Size use A'Component_Size * 8; for A'Component_Size use A'Size - 14; and now the compiler has to figure out how to solve for two variables. I suppose it's possible to write RM rules in such a way as to prevent things like this while allowing the 'Small/'Delta case, but this either requires some pretty complex rules, or rules that just spell out a number of special cases (such as saying "An expression causes freezing except in the one particular clause FOR T'SMALL USE T'DELTA). Neither one is going to be appealing particularly for such a small gain---it doesn't give programmers the ability to do anything that couldn't be accomplished easily with just a tiny bit more effort. Bottom line: it isn't possible to make the language make everything work that looks like it should work. Ada is, after all, a Programming Language and not a Mind-Reading Machine. -- Adam