From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 24C20BB9A for ; Sat, 22 Oct 2005 07:57:09 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j9M5v8lo027673 for ; Sat, 22 Oct 2005 07:57:08 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id HAA09653 for ; Sat, 22 Oct 2005 07:57:08 +0200 (MET DST) Received: from mz1.forethought.net (mzpi3.forethought.net [216.241.36.12]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j9M5v6aY020708 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Sat, 22 Oct 2005 07:57:07 +0200 Received: from [216.241.35.41] (helo=[10.0.0.2]) by mz1.forethought.net with esmtp (Exim 4.51) id 1ETCNK-000176-K0 for caml-list@inria.fr; Fri, 21 Oct 2005 23:57:02 -0600 Message-ID: <4359D4B2.2000509@gushee.net> Date: Fri, 21 Oct 2005 23:57:06 -0600 From: Matt Gushee User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051002) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] Duplicate functionality? References: <0IOQ006I7LO24OK2@vms044.mailsrvcs.net> <200510220431.18749.jon@ffconsultancy.com> In-Reply-To: <200510220431.18749.jon@ffconsultancy.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4359D4B4.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 4359D4B2.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 debugging:01 recursive:01 functor:01 foo:01 foo:01 ocaml:01 ...:98 wrote:01 wrote:01 extensible:01 modules:01 modules:01 checking:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Jon Harrop wrote: >> On Saturday 22 October 2005 02:04, Stephen Brackin wrote: >> > >>>>My biggest initial question is why OCaml has both a modules system and >>>>objects: Aren't they different ways of accomplishing the same things? > >> >> Both modules and objects allow you to encapsulate related definitions, yes. >> >> However, modules are much more static by nature and objects are much more >> dynamic, i.e. you get stronger static checking using modules than you do >> using objects, giving more comprehensible error messages and more robust and >> faster code. That's certainly true ... I've probably spent twice as much time debugging type errors in mutually recursive objects as I have on all other kinds of errors put together. On the other hand (as Jon's statement implies), it's much easier to write extensible code with objects. When you call a function on a module (except within a functor) you are using a specific implementation, whereas you can call an object method, say foo#display (), where foo can be any object with a 'display' method that matches the expected type. And even if modules and objects were functionally equivalent, I think one of the great things about OCaml is the freedom it gives you to structure your application in the best way for the problem. -- Matt Gushee Englewood, CO, USA