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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d8e7e976ead4a812 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-14 11:25:06 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!newsfeed.stanford.edu!logbridge.uoregon.edu!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: Function pointer in Ada? Date: Tue, 14 May 2002 13:24:43 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: <5f4adaeaa2a7b35810acd4e20fb98b25.86200@mygate.mailgate.org> <3ce15027.0@news.unibw-muenchen.de> Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1021400702 35919 137.194.161.2 (14 May 2002 18:25:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 14 May 2002 18:25:02 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:24047 Date: 2002-05-14T13:24:43-05:00 ----- Original Message ----- From: "Kai Schuelke" Newsgroups: comp.lang.ada To: 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.