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!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!feeder.erje.net!eu.feeder.erje.net!bloom-beacon.mit.edu!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Question about name resolution Date: Tue, 20 Jan 2015 15:39:02 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls7.std.com 1421786344 22314 192.74.137.71 (20 Jan 2015 20:39:04 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Tue, 20 Jan 2015 20:39:04 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:RJWQuCnpsywtIlYrnI8AxUSJYLU= Xref: news.eternal-september.org comp.lang.ada:24643 Date: 2015-01-20T15:39:02-05:00 List-Id: "Michael B." writes: > On 01/20/15 20:00, Jeffrey Carter wrote: >> There's no way to call the 1st P by the name P. You could rename it and call it >> by the renamed name. > > It works, thank you! > I found something similar in a library that I want to use. > I was surprised that this compiles without warnings if neither of the > procedures is called. Why is such overloading allowed in Ada? It seems > to make no sense to write a procedure that cannot be called directly. There is an attempt to forbid overloaded declarations that can never be called because of ambiguity. See RM-8.3(26). It's quite complicated, and it doesn't really work -- it has both false positives and false negatives. Your case is a false negative. This rule is followed in the Annotated version by 25 paragraphs of explanatory text! See AARM-8.3(26.a-26.k). And several AI's were needed to fix bugs in this rule. I challenge you to provide wording that would forbid your case, and cases like it. ;-) A modification or addition to 8.3(26), I mean. It's not easy! I think the rule is a waste of time. If you have ambiguous calls, you'll find out at compile time even without that rule, albeit maybe in some other compilation unit. Not a big deal. Here's an example of a false positive: package P is type A is array (Positive range <>) of Integer; function Count(From, Up_To: Integer) return A; -- Returns an array from From up to Up_To, so -- Count(From => 1, Up_To => 4) returns (1, 2, 3, 4). function Count(From, Down_To: Integer) return A; -- Illegal homograph! -- E.g. Count(From => 4, Down_To => 1) returns (4, 3, 2, 1). end P; That's illegal, but if it were legal, you could write nonambiguous calls using named notation. - Bob