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 2A43DBB91 for ; Mon, 10 Jan 2005 16:49:18 +0100 (CET) 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 j0AFnHhE001833 for ; Mon, 10 Jan 2005 16:49:17 +0100 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 QAA30316 for ; Mon, 10 Jan 2005 16:49:17 +0100 (MET) Received: from yquem.inria.fr (yquem.inria.fr [128.93.8.37]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j0AFnHQb027087; Mon, 10 Jan 2005 16:49:17 +0100 Received: by yquem.inria.fr (Postfix, from userid 18180) id 1ECCDBB91; Mon, 10 Jan 2005 16:49:17 +0100 (CET) Date: Mon, 10 Jan 2005 16:49:17 +0100 From: Xavier Leroy To: Christophe TROESTLER Cc: "O'Caml Mailing List" Subject: Re: [Caml-list] Thread safe Str Message-ID: <20050110154917.GA4582@yquem.inria.fr> References: <20050109.203010.110660321.Christophe.Troestler@umh.ac.be> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050109.203010.110660321.Christophe.Troestler@umh.ac.be> User-Agent: Mutt/1.3.28i X-Miltered: at nez-perce with ID 41E2A3FD.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41E2A3FD.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 lgpl:01 pcre:01 regexp:01 compiler:01 thread-safe:01 api:01 regexp:01 apis:01 thread-safe:01 api:01 syntax:01 regexps:01 regexps:01 pairs:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: > The new Str module not only made it LGPL but also very fast (100% more > than Pcre in some cases). However it is still not thread safe -- and > it is not possible given its interface. However, from a quick look, > it seems to me that what is under the hood is almost thread safe. You are correct: the regexp compiler (written in Caml) and the execution engine (written in C) are thread-safe, it's only the API (in Caml) that uses global state. > So why not to write a new module (say Regexp) which would be thread > safe and on top of which Str would be build? That's a very good idea. My initial plan was to have two APIs, the old Str for compatibility and a newer, better designed one for new programs. Besides being thread-safe, the new API could also expose the abstract syntax tree for regexps, allowing easier construction of complex regexps by programs than can be done by working at the level of the string representation of regexps. It's just that I never got to design that new API :-( > This would not be too much work, would it? The implementation work should be quite small indeed, but don't underestimate the work needed to design the API. API design is harder than it seems... But if a few persons on this list want to team up to design an API, that would be wonderful indeed. (A small group is better than individual designers in that several pairs of eyes spot inconsistencies better.) - Xavier Leroy