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=1.2 required=5.0 tests=AWL,DNS_FROM_RFC_POST, INFO_TLD autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 697F7BC0B for ; Tue, 28 Nov 2006 23:48:33 +0100 (CET) Received: from out2.smtp.messagingengine.com (out2.smtp.messagingengine.com [66.111.4.26]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id kASMmWxg020886 for ; Tue, 28 Nov 2006 23:48:32 +0100 Received: from db2.internal (db2.internal [10.202.2.12]) by out1.messagingengine.com (Postfix) with ESMTP id E873C47DDC; Tue, 28 Nov 2006 17:48:32 -0500 (EST) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by db2.internal (MEProxy); Tue, 28 Nov 2006 17:48:32 -0500 X-Sasl-enc: Nx+XQ1KfW9ysKFjpyKBrHEa4ws3TG8XgArU9N4rs82pd 1164754112 Received: from [172.16.112.115] (burnham.ljcrf.edu [192.231.106.2]) by mail.messagingengine.com (Postfix) with ESMTP id 683DB1397A; Tue, 28 Nov 2006 17:48:30 -0500 (EST) Date: Tue, 28 Nov 2006 14:47:47 -0800 (PST) From: Martin Jambon X-X-Sender: martin@localhost To: Till Varoquaux Cc: Philippe Wang , caml-list@inria.fr Subject: Re: [Caml-list] About the O'Reilly book on the web In-Reply-To: <9d3ec8300611281433q5509ccby65937fd4384f5a25@mail.gmail.com> Message-ID: References: <45688DAE.7010309@ccr.jussieu.fr> <456AAABE.5020405@irisa.fr> <456CA3B7.1020508@philippewang.info> <9d3ec8300611281433q5509ccby65937fd4384f5a25@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-j-chkmail-Score: MSGID : 456CBCC0.001 on concorde : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 456CBCC0.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; o'reilly:01 ocaml:01 regexp:01 syntax:01 clashes:01 -warn-error:01 ocaml:01 recursive:01 syntax:01 regexp:01 lri:01 camlp:01 backslash:01 1977:98 wrote:01 On Tue, 28 Nov 2006, Till Varoquaux wrote: > hello! > On 11/28/06, Philippe Wang wrote: > > Hello, > ... > > # "[0-9]+\.[0-9]+\.[0-9]+";; > > - : string = "[0-9]+\\.[0-9]+\\.[0-9]+" > > > > You can probably avoid warnings by backslashing your backslashes... > > > > Still I believe the OCaml Team should find another way to express > > regular expressions, because if \. and \\. both mean \\. then it is a > > very bad idea... > Although I do agree the problem seems a little more complicated: > we are used to a more or less standard regexp syntax where special > chars can be escaped by \, this obviously clashes with escaping > characters in string if we pass strings to the function defining the > regular exceptions.... > I would recommend treating all warnings as errors: > -warn-error A > to avoid such conflicts. > > As far as I'm concerned I find the problem to be more complicated: > regular expressions are not syntaxily checked nor are they typed > checked when specified through strings. Some languages intergrate them > as first class values thus allowing these verifications. Another > solution would be to build them using an Ocaml recursive sum type. > Although this would solve the syntax problem it would make regexp very > tedious to write. A library offering both options can be found at: > http://www.lri.fr/~marche/regexp/ > > Ideally one would want to precompile regular expression from strings > to actual constructed types using a preprocessor (e.g. camlp4). It > seems Francois Potier was one of the first to try such an approach: > [http://caml.inria.fr/pub/ml-archives/caml-list/2001/07/30b327c7c4b0fa5ace86dbf258e2c5d1.en.html] > I'm pretty sure this has been done in other libraries (regexp-pp for > instance). Actual type-checking might prove a little harder to get > working. You should definitely have a look at micmatch. It's backslash free! main page: http://martin.jambon.free.fr/micmatch.html tutorial: http://martin.jambon.free.fr/micmatch-howto.html reference: http://martin.jambon.free.fr/micmatch-manual.html Martin -- Martin Jambon, PhD http://martin.jambon.free.fr