Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] unix.chop_extension
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alex Baretta <alex@b...>
Subject: Re: [Caml-list] unix.chop_extension
skaller wrote:
> # Filename.chop_extension "x.y/z";;
> - : string = "x"

This is a terrible consequence of not having (* functional *) support 
for regexps in the language or standard library. The Filename library 
uses the very weak functions of the String library to find the rightmost 
dot in the filename (* or path *), which is obviously correct only under 
a very stringent precondition, which is not the most general possible 
precondition for this function.

The Str module has a very clever implementation, but it cannot be used 
systematically in Ocaml because it is not *functional*. I'm sure that if 
we had a functional version of Str, the author of the Filename module 
would rewrite it using regular expressions instead of the rindex function.


There's one extra thing I'd like to point out. We have the 
chop_extension function. Why in the world is there no find_extension 

find_extension "" --> "bar"


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: