🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.eiffel
Article #1521

Passing functions as parameters

#1521
From: PAWLOWSKY
Date: Fri, 02 Feb 1990 15:30
24 lines
1651 bytes
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
Technical Details
Message-ID: <1832@clyde.concordia.ca>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!hercule!marcap

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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