From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA28837 for caml-redistribution; Thu, 3 Jul 1997 20:49:54 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA22538 for ; Thu, 3 Jul 1997 11:04:56 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.5/8.7.3) with ESMTP id LAA27295; Thu, 3 Jul 1997 11:04:55 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA22534; Thu, 3 Jul 1997 11:04:54 +0200 (MET DST) From: Xavier Leroy Message-Id: <199707030904.LAA22534@pauillac.inria.fr> Subject: Re: String wishes for Ocaml In-Reply-To: <199707021239.OAA12596@vega.serma.cea.fr> from Basile STARYNKEVITCH at "Jul 2, 97 02:39:43 pm" To: Basile.Starynkevitch@cea.fr (Basile STARYNKEVITCH) Date: Thu, 3 Jul 1997 11:04:54 +0200 (MET DST) Cc: caml-list@inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis > 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). Regards, - Xavier Leroy