From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id A858DD169 for ; Mon, 25 Jul 2005 01:26:08 +0200 (CEST) Received: from conn.mc.mpls.visi.com (conn.mc.mpls.visi.com [208.42.156.2]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j6ONQ7Li011137 for ; Mon, 25 Jul 2005 01:26:08 +0200 Received: from [192.168.42.2] (bhurt.dsl.visi.com [208.42.141.66]) by conn.mc.mpls.visi.com (Postfix) with ESMTP id 07A34812C; Sun, 24 Jul 2005 18:26:07 -0500 (CDT) Date: Sun, 24 Jul 2005 18:26:32 -0500 (CDT) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: skaller Cc: Stephane Glondu , caml-list@yquem.inria.fr Subject: Re: [Caml-list] How to do this properly with OCaml? In-Reply-To: <1122236998.9027.163.camel@localhost.localdomain> Message-ID: References: <200507241113.34003.Stephane.Glondu@crans.org> <1122230923.9027.84.camel@localhost.localdomain> <200507241214.39688.Stephane.Glondu@crans.org> <1122236998.9027.163.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at concorde with ID 42E4238F.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 buffer:01 buffer:01 datatype:01 char:01 bool:01 applicative:01 mutable:01 doubly:01 semantics:01 mutable:01 2005,:98 48,:98 wrote:01 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 On Mon, 25 Jul 2005, skaller wrote: > On Sun, 2005-07-24 at 12:14 -0700, Stephane Glondu wrote: >> On Sunday 24 July 2005 11:48, skaller wrote: >>>> I strongly disagree. Look at source code of buffer.ml: no Obj.magic. >>>> What do you mean by "efficiently"? >>> >>> Buffer only works for characters. >> >> You can make it work for any datatype by using an 'a array option instead >> of a string. > > That fails to be 'efficient'. Would you use > > char array option > > instead of the existing Buffer??? The problem is that there is no one perfect structure. bool array is incredibly inefficient- it's much better to use a bitfield. Etc. As for having a dynamic (resizable) array as a standard library, I think I disagree with this idea. A standard applicative tree-based array, maybe. But a dynamic array, like a mutable doubly linked list, encourages imperitive programming- when I think imperitive programming should be *discouraged*. There are reasons, and time, when imperitive programming is necessary. But I think they are few and far between- much rarer than people suppose. But imperitive semantics impose implicit coupling- when you pass a mutable data structure to a subroutine there is an implicit contract between the caller and callee- either to modify in a known way or to not modify the value at all. This increases coupling and leads to maintainance problems. Brian