caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: Xavier Leroy <Xavier.Leroy@inria.fr>
Cc: skaller <skaller@users.sourceforge.net>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Str replacement
Date: Sun, 05 Aug 2007 21:30:41 +0200	[thread overview]
Message-ID: <1186342242.6285.64.camel@localhost.localdomain> (raw)
In-Reply-To: <46B5F55C.8050201@inria.fr>

Am Sonntag, den 05.08.2007, 18:05 +0200 schrieb Xavier Leroy:
> > When is the Str module going to be extended to provide
> > re-entrant operations??
> 
> When someone designs a new interface to Str and gets it approved by a
> few respectable members of this community.  A proof-of-concept
> implementation wouldn't hurt either, although I'm OK with writing the
> final implementation.  It's the API for which I don't have ideas.

What about this:

https://godirepo.camlcity.org/wwwsvn/trunk/code/src/netstring/netstring_str.mli?rev=1003&root=lib-ocamlnet2&view=auto

This is the reentrant API used in Ocamlnet. Once upon a time it was
really based on Str as backend, but we switched to Pcre for its extended
capabilities. The core idea is that code like

if Str.string_match re s 0 then
  let u = Str.matched_group 1 s in
  do_this
else
  do_something_else

is replaced by

match Str.string_match re s 0 with
  Some m ->
    let u = Str.matched_group m 1 s in
    do_this
| None ->
    do_something_else

which is not very much longer. All intermediate state is kept in m.

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
Phone: +49-6151-153855                  Fax: +49-6151-997714
------------------------------------------------------------


  reply	other threads:[~2007-08-05 19:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-04 10:28 skaller
2007-08-05 16:05 ` [Caml-list] " Xavier Leroy
2007-08-05 19:30   ` Gerd Stolpmann [this message]
2007-08-05 23:22   ` skaller

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=1186342242.6285.64.camel@localhost.localdomain \
    --to=info@gerd-stolpmann.de \
    --cc=Xavier.Leroy@inria.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=skaller@users.sourceforge.net \
    /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;
as well as URLs for NNTP newsgroup(s).