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 X-Google-Thread: 103376,68e7fcc642995ece X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-11 06:08:49 PST Message-ID: <3B24C2C1.CC3C4382@amsjv.com> Date: Mon, 11 Jun 2001 14:08:17 +0100 From: Philip Anderson Organization: Alenia Marconi Systems ISD X-Mailer: Mozilla 4.7 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Calling through function pointer--syntax question References: <9fj5nm$sg0$1@news.netmar.com> <3B1E539E.CF306AC6@averstar.com> <3B1ED74B.BFC95722@acm.org> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: cwmwkn0612.cwmbran.gecm.com X-Trace: 11 Jun 2001 13:59:43 GMT, cwmwkn0612.cwmbran.gecm.com Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!dispose.news.demon.net!demon!btnet-peer0!btnet-feed5!btnet!newreader.ukcore.bt.net!pull.gecm.com!cwmwkn0612.cwmbran.gecm.com Xref: archiver1.google.com comp.lang.ada:8536 Date: 2001-06-11T14:08:17+01:00 List-Id: Simon Wright wrote: > > This has to be the second P. If you were meaning to call the first P, > you would write Would or must? > P (func.all (5)); > > with Ada.Text_Io; use Ada.Text_Io; > Procedure Q is > type Func_Ptr is access function (Param : Integer) return Integer; > function Actual (Param : Integer) return Integer is > begin > return 0; > end Actual; > function Func (Y : Integer := 4) return Func_Ptr is > begin > return Actual'Access; > end Func; > procedure P (X : in Integer) is > begin > Put_Line ("first interpretation"); > end P; > procedure P (X : in Func_Ptr) is > begin > Put_Line ("second interpretation"); > end P; > begin > P (Func (5)); > P (Func.all (5)); > end Q; > > results in > > second interpretation > first interpretation > > (GNAT 3.14a) Using Rational Apex for NT 3.0.2b, this gives an error: *** Unit has semantic errors P could be (in Q) P P could be (in Q) P P (Func (5)); is an ambiguous call Commenting out the second P, it compiles quite happily, resulting in first interpretation first interpretation Likewise, using named parameter association to disambiguate calls P (Func (Param => 5)); P (Func (Y => 5)); P (Func.all (5)); which is accepted, and results in first interpretation second interpretation first interpretation So I think Adam does have a case. Also, either Rational or Gnat appears to have a bug. -- hwyl/cheers, Philip Anderson Alenia Marconi Systems Cwmbr�n, Cymru/Wales