Version française
Home     About     Download     Resources     Contact us    
Browse thread
String wishes for Ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: String wishes for Ocaml
> 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