Newsgroups: comp.object Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!cunixf.cc.columbia.edu!cs.columbia.edu!rmf From: rmf@cs.columbia.edu (Robert M. Fuhrer) Subject: Re: A Hard Problem for Static Type Systems In-Reply-To: dl@g.g.oswego.edu's message of 22 Apr 91 09:56:07 GMT Message-ID: Sender: news@cs.columbia.edu (The Daily News) Organization: Columbia University Department of Computer Science References: <1991Apr20.010347.28984@leland.Stanford.EDU> <3378@charon.cwi.nl> <1991Apr22.015415.28303@leland.Stanford.EDU> Date: 22 Apr 91 14:09:51 Doug Lea (dl@g.oswego.edu) writes: > At first glance, you'd like to type min as something like > > fn min (x: TotalOrder, y: TotalOrder) -> TotalOrder > [...] > But all of this is wrong. > [...] > In fact, declaring the signatures of op<= as I did doesn't even match > standard interpretations of orderings, since you don't want to say > that any op<= can necessarily accept two DIFFERENT TotalOrder subtype > objects, just two from the set under consideration. > [...] > So instead, you'd like to say that any type T is ordered if it obeys > the Partial (Total) ordering PROPERTY rather than is descended from a > PartialOrder supertype. This can be stated in a parametric > polymorphic (`generic') style via something like Let me say that while I agree with the bulk of this posting, I think two separate things are going on. First, there is the issue that single inheritance makes harder certain kinds of sharing (like the "property" sharing mentioned above). [It's not clear to me whether the sharing of important object characteristics is made impossible or not -- I haven't thought about it much, comments are welcome!.] The second is that while we like the idea of the type hierarchy, we run into a problem with enforcing constraints among the actual parameter types. In Mr. Lea's near-solution of the example problem, a simple path to an acceptable solution would be to enforce that the 2 parameters have the *same* type (or compatible types, perhaps in the "property" sense). So, my question is, given that the type hierarchy can be properly factored such that the desired properties are represented by some class, does existential quantification (well, bounded since we have a class structure) (ala Cardelli & Wegner, ACM Surveys, 1985) solve the remaining problem? I.e., does a construct such as exists(T < TotalOrder) such that fn min(x: T, y: T) => T do the trick? If so, is this an example of the "impractical" mechanism Mr. Chambers wants to avoid? If not, what else is going on? -- -------------------------- Robert M. Fuhrer Computer Science Department Columbia University 1117B Fairchild Building Internet: rmf@cs.columbia.edu UUCP: ...!rutgers!cs.columbia.edu!rmf