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,FREEMAIL_FROM autolearn=ham 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 13:00:56 PST From: "Kai Schuelke" Newsgroups: comp.lang.ada References: <5f4adaeaa2a7b35810acd4e20fb98b25.86200@mygate.mailgate.org> <3ce15027.0@news.unibw-muenchen.de> Subject: Re: Function pointer in Ada? Date: Tue, 14 May 2002 22:00:36 +0200 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: bl15-1107.studfb.unibw-muenchen.de Message-ID: <3ce16ccc.0@news.unibw-muenchen.de> X-Trace: 14 May 2002 22:00:12 +0100, bl15-1107.studfb.unibw-muenchen.de Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-han1.dfn.de!news-stu1.dfn.de!news.belwue.de!informatik.tu-muenchen.de!lrz.de!news.unibw-muenchen.de!bl15-1107.studfb.unibw-muenchen.de Xref: archiver1.google.com comp.lang.ada:24057 Date: 2002-05-14T22:00:36+02:00 List-Id: "David C. Hoos" schrieb im Newsbeitrag news:mailman.1021400702.30533.comp.lang.ada@ada.eu.org... [..] > Why you would want to do this, I can't imageine, but here's how it can be > done: [..] That's how I did it. It was for a function-plotter. You put in a String and you get back a pointer to a mathmatical function. It looked like this. I hope you get a idea from this ut down version. If anybody's interessted in it I can send the sources. type Single_Operation is Op : Operator_Pointer; L : Single_Operation_Pointer; R : Single_Operation_Pointer; Parameter : FLOAT; end record; The mathematical function is represented with a tree of Single_Operation. To solve the equation you just have to do a recursive call: function solve(temp : Single_Operation_Pointer) return FLOAT is begin if L /= null then return temp.Op.all(solve(L), solve(R)); else return Parameter; end if; end; The program works, but it would be more elegant if I could get a pointer to the Standard"+" without wrapping a extra function around it. I thought it would be better to use pointers to functions because it is more memory efficient and more flexible, too. Have a good night! Kai Schuelke