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.4 required=5.0 tests=AWL,INFO_TLD,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 7486ABC0B for ; Tue, 28 Nov 2006 23:33:07 +0100 (CET) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.184]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kASMX6ku021616 for ; Tue, 28 Nov 2006 23:33:07 +0100 Received: by nf-out-0910.google.com with SMTP id m19so2594721nfc for ; Tue, 28 Nov 2006 14:33:06 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=S87bGO67TAb5k32NfGG/GINXAQgn5laCLTofXeXIO5oqTBQfk2MaNMN4ETfRBdZY6eXBKNIyq+0yd76+CZevMJHFIZDKNtsYd0Rjv0OYBpvvdwbJftfGR750835+2LIFXw8/SnUjr3khJkVRb9Uaa4eqF92dx45erwfOrFmZEmA= Received: by 10.82.153.5 with SMTP id a5mr284814bue.1164753186307; Tue, 28 Nov 2006 14:33:06 -0800 (PST) Received: by 10.82.153.16 with HTTP; Tue, 28 Nov 2006 14:33:06 -0800 (PST) Message-ID: <9d3ec8300611281433q5509ccby65937fd4384f5a25@mail.gmail.com> Date: Tue, 28 Nov 2006 23:33:06 +0100 From: "Till Varoquaux" To: "Philippe Wang" Subject: Re: [Caml-list] About the O'Reilly book on the web Cc: caml-list@inria.fr In-Reply-To: <456CA3B7.1020508@philippewang.info> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <45688DAE.7010309@ccr.jussieu.fr> <456AAABE.5020405@irisa.fr> <456CA3B7.1020508@philippewang.info> X-j-chkmail-Score: MSGID : 456CB922.001 on discorde : j-chkmail score : X : 0/20 1 X-Miltered: at discorde with ID 456CB922.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 cheers:01 wrote:01 ideally:01 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. Cheers, Till P.S.:Je confirme: j'ai bien recu ton mail ;-)...