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-Thread: 103376,388fc53f584bd695 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news4.google.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Fixed point constants issue Date: Tue, 14 Sep 2010 08:54:20 +0200 Organization: Adalog Message-ID: References: <1f0l0baynq1x7$.phl9cqpwcr37.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 14 Sep 2010 06:54:31 +0000 (UTC) Injection-Info: mx03.eternal-september.org; posting-host="R6XkmKDe5FVL0VlxQ170Ew"; logging-data="3952"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/SJAvC66RPkPNI4QpjenmO" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 In-Reply-To: Cancel-Lock: sha1:tAJ8GOe/wbDZUyqYr8H4DUVoc/w= Xref: g2news1.google.com comp.lang.ada:14068 Date: 2010-09-14T08:54:20+02:00 List-Id: Le 13/09/2010 23:08, Vinzent Hoefler a écrit : >>> And, obviously it does this that when evaluating >>> >>> TEN_FEET_4 : constant Altitude := Altitude (HEIGHT * FEET_PER_METER); >> >> Well, it does not, because here another type is involved. > > Yes. So, the expression HEIGHT * FEET_PER_METER in the one case is > evaluated by using the result type's multiplication operator and if the > conversion is present, it is not, giving the more precise result. > > That's still a bit crazy, IMHO. > Every language with overloading has to decide whether resolution goes from the outside to the inside, or the other way round. In the case of Ada, it is the "enclosing context" that determines the type of what's in it. If the enclosing context is a type conversion, it tells nothing about the expected type of its argument, hence the fall back to universal types. If the enclosing context is typed, it determines the type of the "*" operator. -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr