Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!boulder!gore!jacob From: jacob@gore.com (Jacob Gore) Newsgroups: comp.lang.eiffel Subject: Re: Passing functions as parameters Message-ID: <120012@gore.com> Date: 2 Feb 90 17:04:02 GMT References: <1832@clyde.concordia.ca> Reply-To: jacob@gore.com (Jacob Gore) Organization: Gore Enterprises Lines: 38 / comp.lang.eiffel / marcap@hercule.cs.concordia.ca (PAWLOWSKY) / Feb 2, 1990 / > A while back, the passing of functions as parameters was mentioned. If > memory is correct (I don't have a list of comp.lang.eiffel postings, is > someone out there keeping a ftp'able copy?) it ended up with someone > saying it is not needed since you can redefine the function as needed > in the class. I take this as confirmation that no, you can't pass functions as parameters in Eiffel. Could somebody tell me then what the inheritance-related trick is for supplying a list class with the following routines: 1. apply-routine -- like LISP's "mapcar": same operation repeatedly applied to all elements of the list 2. insert-function -- like APL's "/": given a list L such that nb_elements(L)>1 and a fuction F, if L.nb_elements > 2 then return F(L.first, L.rest) else return F(L.first, L.second) The one particularly useful in Eiffel is a combination of 1 and 2: 3. for-all -- given a BOOLEAN function F and a list L, return 'true' if F(L.i_th(k)) returns true for all 1 <= k <= L.nb_elements And, of course, a there-exists function is analogous. Having such features in list classes would make writing assertions about lists much easier. Jacob -- Jacob Gore Jacob@Gore.Com boulder!gore!jacob