From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA01162 for caml-redistribution; Fri, 29 Jan 1999 09:50:03 +0100 (MET) 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 BAA24029 for ; Fri, 29 Jan 1999 01:25:21 +0100 (MET) Received: from miss.wu-wien.ac.at (miss.wu-wien.ac.at [137.208.107.17]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id BAA21918 for ; Fri, 29 Jan 1999 01:25:19 +0100 (MET) Received: (from mottl@localhost) by miss.wu-wien.ac.at (8.9.0/8.9.0) id BAA22513; Fri, 29 Jan 1999 01:25:16 +0100 (MET) From: Markus Mottl Message-Id: <199901290025.BAA22513@miss.wu-wien.ac.at> Subject: Re: Looking for a nail To: dsyme@microsoft.com (Don Syme) Date: Fri, 29 Jan 1999 01:25:16 +0100 (MET) Cc: caml-list@inria.fr (OCAML) In-Reply-To: <39ADCF833E74D111A2D700805F1951EF0F00B93A@RED-MSG-06> from "Don Syme" at Jan 28, 99 05:32:58 am X-Mailer: ELM [version 2.4 PL21] MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: weis > Yes, I'd be interested to see a really convincing use of the utility of the > OO features, e.g. a program or library which is manifestly shorter, cleaner > and/or simpler when expressed with OO rather than the core features. I > guess people can take this as a challenge if they like :-) I'm open to be > convinced - but I'm not convinced yet. Imagine that all basic types were classes and all of them would support a method e.g. "print". Than you could do the following: let print x = x # print List.iter print [3; "hello"; 3.14; ["yeah, another list!"]] or you want to map various objects to strings: let to_string x = x # to_string List.map to_string [some_object; another_object; 7; 2.7172] Some (general) complex stuff you can do with OO (send some messages to all objects in a container - they do not necessarily have to be members of the same class, they only share parts of interfaces): ASet.iter (fun x -> x#simplify; x#factorize; x#calculate_question 42) s If you want, I show you a zillion similar constructs, which IMHO make life *significantly* more comfortable... I already use this where I can, but if basic types were classes, the first two examples would also work. There is probably hardly any program, where you wouldn't need such constructs. Although modules are a great means of abstraction, show me how you can do such (very readable) things with them. When I began using the OO features, I rewrote some program to use classes instead of (algebraic) types. The code not only became much more readable, but it is much easier to maintain - adding new features takes (in my experience) far less time. Best regards, Markus -- Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl