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-7-bit X-Google-Thread: 103376,68e7fcc642995ece X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-08 23:54:01 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!skynet.be!dispose.news.demon.net!news.demon.co.uk!demon!pogner.demon.co.uk!zap!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Calling through function pointer--syntax question Date: 09 Jun 2001 07:29:51 +0100 Organization: CodeFella Message-ID: References: <9fj5nm$sg0$1@news.netmar.com> <3B1E539E.CF306AC6@averstar.com> <3B1ED74B.BFC95722@acm.org> NNTP-Posting-Host: localhost X-NNTP-Posting-Host: pogner.demon.co.uk:158.152.70.98 X-Trace: news.demon.co.uk 992069600 nnrp-14:10122 NO-IDENT pogner.demon.co.uk:158.152.70.98 X-Complaints-To: abuse@demon.net NNTP-Posting-Date: 9 Jun 2001 06:29:51 GMT X-Newsreader: Gnus v5.7/Emacs 20.7 Xref: archiver1.google.com comp.lang.ada:8478 Date: 2001-06-09T06:29:51+00:00 List-Id: adam@irvine.com (Adam Beneschan) writes: > type func_ptr is access function (param : integer) return integer; > function func (y : integer := 4) return func_ptr; > procedure P (x : in integer); > procedure P (x : in func_ptr); > > and my question is about the procedure call: > > P (func (5)); This has to be the second P. If you were meaning to call the first P, you would write 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)