From: Martin Jambon <martin1977@laposte.net>
To: Till Varoquaux <till.varoquaux@gmail.com>
Cc: Philippe Wang <lists@philippewang.info>, caml-list@inria.fr
Subject: Re: [Caml-list] About the O'Reilly book on the web
Date: Tue, 28 Nov 2006 14:47:47 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.4.58.0611281441560.19624@localhost> (raw)
In-Reply-To: <9d3ec8300611281433q5509ccby65937fd4384f5a25@mail.gmail.com>
On Tue, 28 Nov 2006, Till Varoquaux wrote:
> hello!
> On 11/28/06, Philippe Wang <lists@philippewang.info> 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
next prev parent reply other threads:[~2006-11-28 22:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-25 18:38 Francois Colonna
2006-11-27 9:07 ` [Caml-list] " Sebastien Ferre
2006-11-28 21:01 ` Philippe Wang
2006-11-28 22:33 ` Till Varoquaux
2006-11-28 22:47 ` Martin Jambon [this message]
2006-11-29 0:18 ` Philippe Wang
2006-11-29 1:48 ` Martin Jambon
2006-11-29 15:26 ` Philippe Wang
2006-11-29 17:52 ` Diego Olivier FERNANDEZ PONS
2006-11-29 17:25 ` brogoff
2006-11-29 18:10 ` Philippe Wang
2006-11-30 2:30 ` skaller
2006-11-30 18:20 ` Tom
2006-12-01 3:21 ` skaller
2006-12-01 6:48 ` Tom
2006-11-29 21:20 ` Jon Harrop
2006-11-29 21:25 ` Till Varoquaux
2006-12-01 0:12 ` brogoff
2006-11-28 23:07 ` Philippe Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.58.0611281441560.19624@localhost \
--to=martin1977@laposte.net \
--cc=caml-list@inria.fr \
--cc=lists@philippewang.info \
--cc=till.varoquaux@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox