Re: String wishes for Ocaml

From: Xavier Leroy (
Date: Thu Jul 03 1997 - 11:04:54 MET DST

From: Xavier Leroy <>
Message-Id: <>
Subject: Re: String wishes for Ocaml
In-Reply-To: <> from Basile STARYNKEVITCH at "Jul 2, 97 02:39:43 pm"
Date: Thu, 3 Jul 1997 11:04:54 +0200 (MET DST)

> I have some few small (except the 3rd) wishes for next Ocaml release,
> regarding string processing:
> 1. some more basic string utilities in the standard Ocaml library (not
> the Str package), like [...] strchr in C [...and...] strrchr in C

This is reasonable. Indeed, the Filename standard library module
defines the equivalent of strrchr for its internal usage.

> 2. perhaps something similar to strtok in C (but reentrant)

Str.split (from the OCaml regexp library) is strictly more powerful
than strtok, since it supports arbitrary regexps as delimiters.

> 3. Much harder. A sort of scanf facility. Perhaps the format could be
> a list of formatting element...

When programming in C, I've never found scanf() very useful. It does
not allow enough flexibility in defining the scanning syntax.
I'd rather scan lines the Perl way, using regular expressions
(Str.string_match + extraction of \(...\) components using
Str.matched_string and conversion to int or float if needed).


- Xavier Leroy

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:11 MET