From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 835CCBC69 for ; Sun, 5 Aug 2007 21:30:58 +0200 (CEST) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.177]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l75JUwxu013238 for ; Sun, 5 Aug 2007 21:30:58 +0200 Received: from [84.59.120.150] (helo=gate.lan.gerd-stolpmann.de) by mrelayeu.kundenserver.de (node=mrelayeu0) with ESMTP (Nemesis), id 0MKwh2-1IHloM3Ztj-0000RM; Sun, 05 Aug 2007 21:30:47 +0200 Received: from flakew.lan.gerd-stolpmann.de (fw.lan.gerd-stolpmann.de [192.168.1.1]) by gate.lan.gerd-stolpmann.de (Postfix) with ESMTP id 7E5CDC088; Sun, 5 Aug 2007 21:30:46 +0200 (CEST) Subject: Re: [Caml-list] Str replacement From: Gerd Stolpmann To: Xavier Leroy Cc: skaller , caml-list@yquem.inria.fr In-Reply-To: <46B5F55C.8050201@inria.fr> References: <1186223315.14440.64.camel@rosella.wigram> <46B5F55C.8050201@inria.fr> Content-Type: text/plain Date: Sun, 05 Aug 2007 21:30:41 +0200 Message-Id: <1186342242.6285.64.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX1/ixw57Y1cHq8LlOWwsiRAXa0Umz4Kgg5CuQIR T/knP2hv3O186ItLesCi6xKhVqorcPkjnZnZjPgN36pzjE/5S3 28mbCJir13qJWD4tM4vE/Zk8x09Zes0 X-Miltered: at concorde with ID 46B62572.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; gerd:01 stolpmann:01 netstring:01 netstring:01 mli:01 ocamlnet:01 pcre:01 gerd:01 stolpmann:01 viktoriastr:01 64293:01 darmstadt:01 6151:01 6151:01 respectable:98 Am Sonntag, den 05.08.2007, 18:05 +0200 schrieb Xavier Leroy: > > When is the Str module going to be extended to provide > > re-entrant operations?? > > When someone designs a new interface to Str and gets it approved by a > few respectable members of this community. A proof-of-concept > implementation wouldn't hurt either, although I'm OK with writing the > final implementation. It's the API for which I don't have ideas. What about this: https://godirepo.camlcity.org/wwwsvn/trunk/code/src/netstring/netstring_str.mli?rev=1003&root=lib-ocamlnet2&view=auto This is the reentrant API used in Ocamlnet. Once upon a time it was really based on Str as backend, but we switched to Pcre for its extended capabilities. The core idea is that code like if Str.string_match re s 0 then let u = Str.matched_group 1 s in do_this else do_something_else is replaced by match Str.string_match re s 0 with Some m -> let u = Str.matched_group m 1 s in do_this | None -> do_something_else which is not very much longer. All intermediate state is kept in m. Gerd -- ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de Phone: +49-6151-153855 Fax: +49-6151-997714 ------------------------------------------------------------