From: Tucker Taft <stt@averstar.com>
Subject: Re: Calling through function pointer--syntax question
Date: Mon, 11 Jun 2001 13:34:59 -0400
Date: 2001-06-11T17:34:58+00:00 [thread overview]
Message-ID: <3B250143.CF413609@averstar.com> (raw)
In-Reply-To: b4682ab7.0106081334.2f14ea61@posting.google.com
[-- Attachment #1: Type: text/plain, Size: 1864 bytes --]
Adam Beneschan wrote:
> ...
> At the risk of being taunted a second time, and possibly even having a
> cow hurled down on top of me (or perhaps some other unit of
> livestock), I feel that I need to respond again.
Despite my earlier response, I now agree with you.
I hadn't looked at your example closely enough the
first time.
> ...
> Anyway, it seems to me that the procedure call in question *is*
> ambiguous, contrary to what everyone else (including someone's
> compiler) says, and I'll try to explain in more precise detail why I
> think so:
>
> The relevant declarations are:
>
> 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));
>
> Obviously, one acceptable interpretation is that "func" is called with
> the parameter 5, returning a func_ptr, and this func_ptr is passed to
> the second P.
>
> I believe the other interpretation is also acceptable, however: "func"
> is called with a default parameter, 4. This returns a function
> pointer. This function pointer is dereferenced, and the designated
> function is called with the parameter 5. This returns an integer, and
> the resulting integer is passed to the first P.
Yes, I agree with your analysis.
> ... Is there an error in my
> line of thought?
No.
(And my favorite Ada front end agrees with you too -- I should
have checked with it first!)
[I have attached a listing.]
>
> -- thanks, Adam
--
-Tucker Taft stt@avercom.net http://www.avercom.net
Chief Technology Officer, AverCom Corporation (A Titan Company)
Burlington, MA USA (AverCom was formerly the Commercial Division of AverStar:
http://www.averstar.com/~stt)
[-- Attachment #2: test_ambig.ada.lst --]
[-- Type: text/plain, Size: 670 bytes --]
Source file: test_ambig.ada Mon Jun 11 13:30:34 2001
1 procedure test_ambig is
2 type func_ptr is access function (param : integer) return integer;
3 function func (y : integer := 4) return func_ptr is begin return null; end;
4 procedure P (x : in integer) is begin null; end;
5 procedure P (x : in func_ptr) is begin null; end;
6
7 -- and my question is about the procedure call:
8
9 begin
10
11 P (func (5));
*
*****Error: LRM:8.6(31) Ambiguous call, possible definitions of P appear at
***** line 5 of file test_ambig.ada, line 4 (same file).
12
13 end;
14
15
prev parent reply other threads:[~2001-06-11 17:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-05 17:43 Calling through function pointer--syntax question adam
2001-06-05 19:39 ` tmoran
2001-06-06 16:17 ` Adam Beneschan
2001-06-06 16:00 ` Tucker Taft
2001-06-06 22:06 ` Adam Beneschan
2001-06-07 1:22 ` Jeffrey Carter
2001-06-08 21:34 ` Adam Beneschan
2001-06-09 6:29 ` Simon Wright
2001-06-11 13:08 ` Philip Anderson
2001-06-11 17:34 ` Tucker Taft [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox