Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!mcsun!ukc!newcastle.ac.uk!turing!ncmh From: Chris.Holt@newcastle.ac.uk (Chris Holt) Newsgroups: comp.object Subject: Re: Objects and Interactions: Separate Definitions Message-ID: <1991May23.154839.11831@newcastle.ac.uk> Date: 23 May 91 15:48:39 GMT References: <3999@motcsd.csd.mot.com> <1991May21.064913.16149@netcom.COM> <1991May22.012821.12048@tkou02.enet.dec.com> <1991May22.183044.5634@Think.COM> Sender: news@newcastle.ac.uk Distribution: comp Organization: University of Newcastle upon Tyne, UK, NE1 7RU Lines: 30 barmar@think.com (Barry Margolin) writes: >In article <1991May22.012821.12048@tkou02.enet.dec.com> diamond@jit533.enet@tkou02.enet.dec.com (Norman Diamond) writes: >>Responsibility for specifying a "<" operation belongs to the call site. >Which then requires the call site to know about all the possible types of >things it will compare, which is contrary to object orientation. I don't understand this. The call site has access to the type of thing being compared, or it wouldn't be able to build the structure that is to be sorted; and if it's got the type, it should have the operations that go with that type. Presumably, an ordering relation is one of these. If the caller doesn't know the ordering relation, why should it care whether the structure is sorted or not? >The problem you're running into is that there is more than one way to >compare two objects, but we'd like the generic sorter to simply use a >generic comparison operator. But there isn't always a "generic" comparison operator; unless you're happy with such things as sorting hash values derived from unique identifiers. >There's no such thing as a generic sort or a generic comparison operator. A generic sort is one that accepts a comparison operator as a parameter. ----------------------------------------------------------------------------- Chris.Holt@newcastle.ac.uk Computing Lab, U of Newcastle upon Tyne, UK ----------------------------------------------------------------------------- "They have been at a great feast of languages, and stolen the scraps." - WS