From: "David C. Hoos" <david.c.hoos.sr@ada95.com>
Subject: Re: Function pointer in Ada?
Date: Tue, 14 May 2002 13:24:43 -0500
Date: 2002-05-14T13:24:43-05:00 [thread overview]
Message-ID: <mailman.1021400702.30533.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: 3ce15027.0@news.unibw-muenchen.de
----- Original Message -----
From: "Kai Schuelke" <kai.schuelke@gmx.net>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: Tuesday, May 14, 2002 12:58 PM
Subject: Re: Function pointer in Ada?
> Hello,
>
> I managed to get a function pointer (left, right : FLOAT) return FLOAT but
I
> couldn't manage to get a pointer to the according Standard."+". I tried
> various ways but had to use a workaround. Is it possible to do something
> like:
>
> plus_pointer : pointer_type := access Standard."+";
>
Why you would want to do this, I can't imageine, but here's how it can be
done:
First, since you are not allowed to take the 'Access attribute of an
intrinsic
function, I "wrapped" the Standard (intrinsic) function in a user-defined
function, then took the 'Access attribute of that.
The code to demonstrate it is here:
with Ada.Text_IO;
procedure Standard_Function_Access
is
type Dyadic_Float_Access is access
function (Left, Right : Float) return Float;
function "+" (Left, Right : Float) return Float
is
begin
return Standard."+" (Left, Right);
end "+";
Float_Plus_Access : constant Dyadic_Float_Access := "+"'Access;
begin
Ada.Text_IO.Put_Line
("3.1 + 7.2 =" & Float'Image
(Float_Plus_Access (3.1, 7.2)));
end Standard_Function_Access;
I also took the liberty of using "Adaesque" names for the declarations.
next prev parent reply other threads:[~2002-05-14 18:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-14 12:51 Function pointer in Ada? Henrik Quintel
2002-05-14 13:08 ` Markus Knauss
2002-05-14 13:12 ` Marin David Condic
2002-05-14 14:36 ` Alfred Hilscher
2002-05-14 17:58 ` Kai Schuelke
2002-05-14 18:01 ` Preben Randhol
2002-05-14 18:24 ` David C. Hoos [this message]
2002-05-14 20:00 ` Kai Schuelke
2002-05-14 18:25 ` Marin David Condic
2002-05-15 22:30 ` Kai Schuelke
2002-05-16 11:37 ` Marc A. Criley
2002-05-16 19:06 ` Kai Schuelke
2002-05-16 19:18 ` Preben Randhol
2002-05-16 12:53 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox