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.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, FROM_STARTS_WITH_NUMS autolearn=no autolearn_force=no version=3.4.4 X-Received: by 10.36.41.138 with SMTP id p132mr20907661itp.13.1516384264806; Fri, 19 Jan 2018 09:51:04 -0800 (PST) X-Received: by 10.157.14.142 with SMTP id 14mr440061otj.2.1516384264586; Fri, 19 Jan 2018 09:51:04 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.szaf.org!news.unit0.net!peer01.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!w142no775262ita.0!news-out.google.com!b73ni2546ita.0!nntp.google.com!g80no773705itg.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 19 Jan 2018 09:51:04 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=85.245.162.133; posting-account=rhqvKAoAAABpikMmPHJSZh4400BboHwT NNTP-Posting-Host: 85.245.162.133 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <310b1dea-459b-4a8b-b249-5bb63ea43512@googlegroups.com> Subject: On naming space and the good use of qualified expression From: Mehdi Saada <00120260a@gmail.com> Injection-Date: Fri, 19 Jan 2018 17:51:04 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Body-CRC: 2996710285 X-Received-Bytes: 2706 Xref: reader02.eternal-september.org comp.lang.ada:50004 Date: 2018-01-19T09:51:04-08:00 List-Id: 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. But I got the same error with or without qualified expression: p_poly_v1_g.adb:82:71: expected private type "T_Rational" defined at p_rationals_g.ads:11, instance at p_poly_v1_g.ads:19 p_poly_v1_g.adb:82:71: found type "Standard.Integer" Was I mistaken about qualified expressions ? How can I express myself so that the compiler understand, BESIDES prefixing every single operators with P_Rationals, which is ugly. I try to understand the use of "use type" and use "all type ...", but I don't manager to for the moment. The language doesn't help, when confronted with new technical stuff. I get it better through exemples...