From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 6720CBC84 for ; Mon, 14 Mar 2005 13:57:48 +0100 (CET) Received: from furbychan.cocan.org (furbychan.cocan.org [80.68.91.176]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j2ECvjYS030001 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Mon, 14 Mar 2005 13:57:48 +0100 Received: from rich by furbychan.cocan.org with local (Exim 3.35 #1 (Debian)) id 1DAp8U-000509-00; Mon, 14 Mar 2005 12:57:30 +0000 Date: Mon, 14 Mar 2005 12:57:29 +0000 To: Pascal Zimmer Cc: Oliver Bandel , caml-list@yquem.inria.fr Subject: Re: [Caml-list] immutable Strings? Message-ID: <20050314125728.GA17687@furbychan.cocan.org> References: <20050312205011.GA2244@first.in-berlin.de> <423567E1.1030909@sophia.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <423567E1.1030909@sophia.inria.fr> User-Agent: Mutt/1.3.28i From: Richard Jones X-Miltered: at nez-perce with ID 42358A49.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 naming:01 'open:01 mutable:01 oliver:01 mutable:01 struct:01 struct:01 prerr:01 endline:01 sig:01 sig:01 val:01 char:01 foo:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Mon, Mar 14, 2005 at 11:30:57AM +0100, Pascal Zimmer wrote: > - you cannot use the shortcuts s.[i] and (^) anymore (this gets the code > less readable especially for the first one) You can get the s.[i] shortcut by naming your module 'ImmString.String' (using a nested module in other words) and using 'open ImmString'. However this has the further problem that you then can no longer use mutable strings :-( although perhaps Oliver has forsworn use of mutable strings, so this is an acceptable compromise for him. # module ImmString = struct module String = struct let get s i = prerr_endline "hello!"; 'c' end end;; module ImmString : sig module String : sig val get : 'a -> 'b -> char end end # open ImmString;; # "foo".[3];; hello! - : char = 'c' Rich. -- Richard Jones, CTO Merjis Ltd. Merjis - web marketing and technology - http://merjis.com Team Notepad - intranets and extranets for business - http://team-notepad.com