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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.unit0.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: On naming space and the good use of qualified expression Date: Fri, 19 Jan 2018 20:37:15 +0200 Organization: Tidorum Ltd Message-ID: References: <310b1dea-459b-4a8b-b249-5bb63ea43512@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 8mF4A528k5MqzZ3NQqx88gRtjVBZiApbwkxmGtFtNtKctgPEur Cancel-Lock: sha1:QhZRrPeN1uFmDOW6ruf7ojPVwHc= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: <310b1dea-459b-4a8b-b249-5bb63ea43512@googlegroups.com> Xref: reader02.eternal-september.org comp.lang.ada:50007 Date: 2018-01-19T20:37:15+02:00 List-Id: On 18-01-19 19:51 , Mehdi Saada wrote: > At that point of the program, I have three "/" operators visibles: > function "/" (A: T_Rational, B: T_Rational) return T_Rational; > function "/" (A: T_Integer, B: T_Integer) return T_Integer; > function "/" (A: T_Integer, B: T_Integer) return T_Rational; -- my constructor method > which makes this expression ambiguous: > Result.Coef(Ind) := Poly_A.Coef(Ind+1) * (Ind+1)/1; > (Coef is an array of T_Rational, Ind is of the same type as the index) > > For the first time, I grasp what "namespace polution" means. > I overestimated the compiler's smartness. I tried then: > Result.Coef(Ind) := Poly_A.Coef(Ind+1) * T_Rational'((Ind+1)/1); > As I thought qualified expression were a means to inform the compiler > of the intended type of the parenthesed expression, so that it could > choose based on the litteral inside AND the different visible homonymous > functions. Perhaps you also have a set of overloaded "+" operators, and the confusion is in the expression Ind+1 ? That is, should the computation be: Ind + 1, as Integer + Integer -> Rational followed by (Ind + 1) / 1, as Rational / Integer -> Rational ? Or should it be: Ind + 1, as Integer + Integer -> Integer followed by (Ind + 1) / 1, as Integer / Integer -> Rational ? Just a guess, of course... -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .