Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!hercule!marcap From: marcap@hercule.cs.concordia.ca (PAWLOWSKY) Newsgroups: comp.lang.eiffel Subject: Passing functions as parameters Summary: I need to do it, and a nice solution would be useful. Message-ID: <1832@clyde.concordia.ca> Date: 2 Feb 90 15:30:36 GMT Sender: usenet@clyde.concordia.ca Reply-To: marcap@hercule.CS.Concordia.CA (PAWLOWSKY) Organization: Concordia University, Montreal Quebec Lines: 24 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. This is not always good enough. Take the example of a class student, with attributes gpa, name, id_no. We also have a database called PUPILS. In PUPILS a function is needed to return a SORTED_LIST[STUDENT] by id_no. No trouble, just define the COMPARABLE operations in terms of id_no in STUDENT. BUT we also want to have a function return a SORTED_LIST[STUDENT] by gpa. What do we do here? A solution would be to create a descendant of SORTED_LIST just for STUDENT's that would have hard coded the use of its members gpa for comparison. And if we wanted it by name, another class. This could get quite large and messy if we need many different orderings. I believe that a much better solution would be to have the function that is to make the comparison passed. Marc Pawlowsky Concordia University Montreal, Quebec, Canada