Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
About the O'Reilly book on the web
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-11-28 (22:48)
From: Martin Jambon <martin1977@l...>
Subject: Re: [Caml-list] About the O'Reilly book on the web
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:
> 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:
> []
> 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:


Martin Jambon, PhD