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 NAA27612; Wed, 26 May 2004 13:20:20 +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 NAA27005; Wed, 26 May 2004 13:20:19 +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 i4QBKISH017575; Wed, 26 May 2004 13:20:18 +0200 Received: from baretta.com (localhost.localdomain [127.0.0.1]) by alex.baretta.com (8.12.8/8.12.8) with ESMTP id i4QBL1Rr002501; Wed, 26 May 2004 13:21:02 +0200 Message-ID: <40B47D9D.1050007@baretta.com> Date: Wed, 26 May 2004 13:21:01 +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: Xavier Leroy , Ocaml , pascky@barettadeit.com Subject: Re: [Caml-list] unix.chop_extension References: <1085429093.6065.336.camel@pelican.wigram> <20040526110508.A17806@pauillac.inria.fr> In-Reply-To: <20040526110508.A17806@pauillac.inria.fr> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 40B47D72.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 api:01 apis:01 chop:01 foo:01 usefulness:01 duality:01 model:01 duality:01 pervasives:01 regexp:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Xavier Leroy wrote: > 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. Actually, I'm a happy user of Str, but I find the absence in Ocaml of a functional "canonical" regexp feature striking. >>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. find_extension would be no more and no less general than chop_extension. It's actually the dual of the latter, in a way. Again, it's no big deal, but it seems to me that the lack of a find_extension function in Filename is an involuntary omission rather than a well thought out design decision. *** Are the following two pieces of code not dual of each other? Is this not a good enough reason to include the former? let file_extension name = try let index = String.rindex name '.' + 1 in let ext_len = String.length name - index in String.sub name index ext_len with Not_found -> invalid_arg "Xcaml.file_extension" let chop_extension name = try String.sub name 0 (String.rindex name '.') with Not_found -> invalid_arg "Filename.chop_extension" Duality is a property I consider of paramount importance in a formal model. Ocaml is a modeling language for algorithms. Duality is central to Ocaml, in my opinion. For this very same reason I once asked why such a crucial operator as ++ had not been included in Pervasives. 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