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 LAA20211; Wed, 26 May 2004 11:05:10 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA20382 for ; Wed, 26 May 2004 11:05:10 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i4Q959EV009255; Wed, 26 May 2004 11:05:09 +0200 Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA19925; Wed, 26 May 2004 11:05:08 +0200 (MET DST) Date: Wed, 26 May 2004 11:05:08 +0200 From: Xavier Leroy To: skaller Cc: caml-list Subject: Re: [Caml-list] unix.chop_extension Message-ID: <20040526110508.A17806@pauillac.inria.fr> References: <1085429093.6065.336.camel@pelican.wigram> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <1085429093.6065.336.camel@pelican.wigram>; from skaller@users.sourceforge.net on Tue, May 25, 2004 at 06:04:53AM +1000 X-Miltered: at nez-perce with ID 40B45DC5.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 chop:01 chop:01 bug:01 basename:01 baretta:01 terrible:01 regexps:01 stdlib:01 stdlib:01 ocamlc:01 regexps:01 asmcomp:01 asmpackager:01 api:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk John Skaller writes: > # Filename.chop_extension "x.y/z";; > - : string = "x" > > Oh come on. This is correct according to the specs, > but no one would believe this function is chopping > off the extension here :) Care to submit a bug report for that? > Also > let y = (concat (directory x) (basename x)) in > assert x = y > is not guarranteed, only that x,y are 'equivalent'. > What does that mean? That both names (x and y) refer to the same file. You access the same file if you open one or the other. Alex Baretta writes: > This is a terrible consequence of not having (* functional *) support > for regexps in the language or standard library. [...] > 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. You're jumping to conclusions here. Str is an external library, not part of the standard library (stdlib). The way the OCaml distribution is set up, stdlib code can only refer to other stdlib modules; the compilers and tools can use stdlib and their own modules; and other libraries such as Str are outside the stdlib/compiler subset. This stratification is important because of bootstrapping issues. It's always a good idea to minimize the bootstrapping base, which currently consists of stdlib, ocamlc and ocamllex. So, it's true that parts of stdlib and the compilers would benefit from regexps (see e.g. asmcomp/asmpackager.ml), but the reason for not using regexps has nothing to do with the imperative interface of Str. Concerning the Str interface, I received several complaints about it, to which I replied "why don't you propose an alternate functional API?", to which I never got any reply. So, if you have ideas, go ahead. If you can get some peer reviewing on your design, that would be much better. Good APIs aren't easy to design (witness the lengthy discussion on I/O on this list), so it's unlikely that you can find a good one all by yourself in 30 minutes. > 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" Why in the world would that be generally useful? Remember, we don't shoot for completeness (it's unattainable anyway), just for usefulness. - Xavier Leroy ------------------- 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