comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@on2.com (Matthew Heaney)
Subject: Re: Charles: Generic_Find
Date: 13 Nov 2002 11:18:38 -0800
Date: 2002-11-13T19:18:38+00:00	[thread overview]
Message-ID: <1ec946d1.0211131118.53b9e943@posting.google.com> (raw)
In-Reply-To: 3dd082fe$0$307$bed64819@news.gradwell.net

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



      parent reply	other threads:[~2002-11-13 19:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-11 17:16 Charles: Generic_Find Victor Porton
2002-11-12  8:07 ` tmoran
2002-11-12  8:27 ` Preben Randhol
2002-11-12 13:48   ` Hyman Rosen
2002-11-12 14:49     ` Frank J. Lhota
2002-11-13 19:31       ` Matthew Heaney
2002-11-13 19:19   ` Matthew Heaney
2002-11-14 10:03     ` Preben Randhol
2002-11-13 19:18 ` Matthew Heaney [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