Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!hub!eiffel!bertrand From: bertrand@eiffel.UUCP (Bertrand Meyer) Newsgroups: comp.lang.eiffel Subject: Re: -> in (polymorphic) class definition Summary: Constrained genericity Keywords: Eiffel, class definition Message-ID: <179@eiffel.UUCP> Date: 13 Jul 89 20:02:03 GMT References: <610@unipas.fmi.uni-passau.de> Organization: Interactive Software Engineering, Santa Barbara CA Lines: 29 From <610@unipas.fmi.uni-passau.de> by stabl@unipas.fmi.uni-passau.de (Robert Stabl): > I have a question about the Eiffel [basic library] class "SORTED_LIST". > > The definition of SORTED_LIST starts with the following line: > class SORTED_LIST [ T -> COMPARABLE ] export .... > > What does the '->' stand for? Since no one else seems to have answered let me explain. This is ``constrained genericity'', which means that any actual generic parameter used for the formal T generic parameter should be a descendant of class COMPARABLE, that is to say equipped with operations <=, <, > etc. For some reason that I don't recall (probably just time constraints) this important facility did not find its way into the book ``Object-Oriented Software Construction'' - more precisely, chapter 19, ``Genericity versus Inheritance'', where it belongs. The only glimpse of it is exercise 19.5, where it is discussed in the conditional (``Consider the usefulness of an extension...''). Constrained genericity is described in the 2.1 Eiffel User's Manual, as well as in the new Eiffel Reference Manual distributed with 2.2. -- Bertrand Meyer bertrand@eiffel.com