English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2004-05-25 (08:46)
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 "foo.bar" --> "bar"


To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners