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,3d6e3f68a9ab5a3c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-13 11:18:38 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Charles: Generic_Find Date: 13 Nov 2002 11:18:38 -0800 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0211131118.53b9e943@posting.google.com> References: <3dd082fe$0$307$bed64819@news.gradwell.net> NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1037215118 6980 127.0.0.1 (13 Nov 2002 19:18:38 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 13 Nov 2002 19:18:38 GMT Xref: archiver1.google.com comp.lang.ada:30827 Date: 2002-11-13T19:18:38+00:00 List-Id: porton@ex-code.com (Victor Porton) wrote in message news:<3dd082fe$0$307$bed64819@news.gradwell.net>... > Why Generic_Find is generic? Why not just pass the predicate > as a function access? Doing so would avoid the need of > generic instantiation. I suggest to change this. The generic version of find is generic because Ada doesn't have downward closures. You have to be able to do something like this: type Employee_Type is record SSN : SSN_Type; ... end record; Employees : Container_Subtype; function Find (SSN : SSN_Type) return Iterator_Type is function Predicate (E : Employee_Type) return Boolean is begin return E.SSN = SSN; end; function Find is new Generic_Find (Predicate); begin return Find (First (Employees), Back (Employees)); end; Function pointers exist in Ada to implement callbacks, from say, a GUI. Unless you need a callback, you should be passing subprograms as generic formal subprogram parameters. Your suggestion is noted, and rejected. Matt