From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA10388; Tue, 25 May 2004 10:46:09 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 KAA10413 for ; Tue, 25 May 2004 10:46:08 +0200 (MET DST) Received: from alex.baretta.com ([213.255.109.130]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i4P8k6SH002269 for ; Tue, 25 May 2004 10:46:07 +0200 Received: from baretta.com (localhost.localdomain [127.0.0.1]) by alex.baretta.com (8.12.8/8.12.8) with ESMTP id i4P8klNp002356; Tue, 25 May 2004 10:46:50 +0200 Message-ID: <40B307F7.6060405@baretta.com> Date: Tue, 25 May 2004 10:46:47 +0200 From: Alex Baretta User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: it, en-us, en MIME-Version: 1.0 To: skaller@users.sourceforge.net, Ocaml Subject: Re: [Caml-list] unix.chop_extension References: <1085429093.6065.336.camel@pelican.wigram> In-Reply-To: <1085429093.6065.336.camel@pelican.wigram> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 40B307CF.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; baretta:01 baretta:01 caml-list:01 chop:01 chop:01 terrible:01 regexps:01 stringent:99 precondition:01 precondition:01 foo:01 ocaml:01 alex:01 alex:01 unix:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 function? find_extension "foo.bar" --> "bar" Alex ------------------- 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