caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@inria.fr>
To: skaller <skaller@users.sourceforge.net>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] unix.chop_extension
Date: Wed, 26 May 2004 11:05:08 +0200	[thread overview]
Message-ID: <20040526110508.A17806@pauillac.inria.fr> (raw)
In-Reply-To: <1085429093.6065.336.camel@pelican.wigram>; from skaller@users.sourceforge.net on Tue, May 25, 2004 at 06:04:53AM +1000

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


  parent reply	other threads:[~2004-05-26  9:05 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-24 20:04 skaller
2004-05-24 22:01 ` skaller
2004-05-25  8:46 ` Alex Baretta
2004-05-25  9:35   ` skaller
2004-05-25  9:46     ` Alain Frisch
2004-05-25 10:47       ` skaller
2004-05-25 11:51         ` sejourne kevin
2004-05-26 11:18           ` Florian Hars
2004-05-25 14:06         ` [Caml-list] Re: AAP (was: unix.chop_extension) Christophe TROESTLER
2004-05-25 13:37     ` [Caml-list] unix.chop_extension John Goerzen
2004-05-25 19:17     ` Richard Jones
2004-05-27  8:15   ` YANG Shouxun
2004-05-27  9:47     ` skaller
2004-05-26  9:05 ` Xavier Leroy [this message]
2004-05-26  9:35   ` Luca Pascali
2004-05-26  9:56   ` Remi Vanicat
2004-05-26 10:34   ` skaller
2004-05-26 13:27     ` Damien Doligez
2004-05-26 15:50       ` skaller
2004-05-26 16:04         ` Damien Doligez
2004-05-27  4:33           ` skaller
2004-05-27  4:56             ` John Goerzen
2004-05-28 16:44             ` Damien Doligez
2004-05-28 19:34               ` skaller
2004-05-29  8:37                 ` Damien Doligez
2004-05-29 10:01                   ` skaller
2004-05-29 16:02                     ` David Brown
2004-05-26 11:21   ` Alex Baretta
2004-05-26 16:43     ` Richard Jones
2004-05-27  4:48       ` skaller
2004-05-27  7:46         ` Markus Mottl
2004-05-27  9:33           ` skaller
2004-05-27 17:29       ` brogoff
2004-05-28 12:00         ` Keith Wansbrough
2004-05-28 16:43           ` brogoff
2004-05-28 17:49             ` Marcin 'Qrczak' Kowalczyk
2004-05-28 11:23       ` Alex Baretta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040526110508.A17806@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=skaller@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).