From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA22091; Sat, 20 Jul 2002 19:30:44 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA22053 for ; Sat, 20 Jul 2002 19:30:43 +0200 (MET DST) Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.25.148.40]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g6KHUej12661 for ; Sat, 20 Jul 2002 19:30:41 +0200 (MET DST) Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id g6KHUbSs005673; Sun, 21 Jul 2002 03:30:37 +1000 (EST) Received: from ozemail.com.au (ppp175.dyn26.pacific.net.au [61.8.26.175]) by wisma.pacific.net.au with ESMTP id DAA15239; Sun, 21 Jul 2002 03:30:35 +1000 (EST) Message-ID: <3D399E3A.9060500@ozemail.com.au> Date: Sun, 21 Jul 2002 03:30:34 +1000 From: John Max Skaller User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2.1) Gecko/20010901 X-Accept-Language: en-us MIME-Version: 1.0 To: Brian Smith CC: caml-list@inria.fr Subject: Re: [Caml-list] productivity improvement References: <20020716172916.4903.qmail@web10702.mail.yahoo.com> <200207190358.XAA11620@dewberry.cc.columbia.edu> <20020719010318.B3631@boson.den.co.bbnow.net> <200207190821.EAA09974@hickory.cc.columbia.edu> <3D37D474.2551F19E@ps.uni-sb.de> <3D37E669.6050608@baretta.com> <3D38573E.2030908@ozemail.com.au> <3D385B6D.9090505@uiowa.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Brian Smith wrote: > John Max Skaller wrote: > >> Alessandro Baretta wrote: >> No. (class based) object orientation is utterly flawed as a paradigm, >> as can be seen by posing the trivial problem of representing any type > > > with a binary operator. > >> It just can't be done, the problem is called 'covariance problem'. >> >> I find it hard to state what the problem is here, but I'll try: >> the problem is you can write an unimplementable interface >> and not get a type error: >> >> struct X { virtual bool binop(X const&)const=0; }; > > > Do you really mean _all_ class-based object orientation? Don't > multimethods and/or overloading help in this case? I don't understand really. The requirment is for an interface specification and (the possibility of) multiple representations. Multimethods are just a slightly more sophisticated dispatch technique, they necessarily break object encapsulation, and there is still no way to represent n squared functions any way other than with n squared functions. :-) Does overloading help? Sure. It is the only solution. More precisely, a convenient syntax for naming the n squared functions. > > > bool equals(x : 'a, y : 'b) = false ; > bool equals(x : Integer, y : Integer) = x.intValue() = y.intValue() ; > bool equals(x : String, y : String) = (* compare all the chars *) ; Both these cases show a common representation. What is the type of x.intValue()? Obviously this is bogus. There is a total loss of abstraction. Clearly, the only type of Integer of any use at all is 'int'. Obviously won't work for 'long long int'. ;-) The second case is more interesting, since the String contents are concrete, but the representation of the sequencing of them internally is abstracted. In other words, different implementations can exist of the *same* type String. This is a good use of class based object orientation (providing one level of representation independence). Q: Why does it work? A: because the characteristic methods of the abstraction x.get(i) // get nth char x.set(i,c) // set ith char to c have *invariant* arguments. In particular, i and c are specific concrete types. > bool equals(x : String, y : Integer) = equals(x, y.toString()) ; Urg :-) > > This seems to be what Nice does. Nice is based on the > ML(less-than-or-equal) type system. > > Perhaps, your comments only apply to a certain subset of class-based > object-orietned languages? My comment applies to considering object orientation as a *paradigm*. It is language independent, entailing mutable objects, encapsulation, and subtyping (possibly via inheritance). Ocaml and C++ are both object oriented languages, and they are both better than pure ones precisely because classes are only one available technique. Classes are useful, dynamic *linear* dispatch is not to be sneered at. (and multimethod research is useful, to find 'almost linear' dispatch techniques). [linear dispatch uses an indexed table lookup, and so is constant time] -- John Max Skaller, mailto:skaller@ozemail.com.au snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia. voice:61-2-9660-0850 ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners