caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Oliver Bandel <oliver@first.in-berlin.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Bug in Filename.basename?
Date: Thu, 06 Sep 2007 14:52:45 +1000	[thread overview]
Message-ID: <1189054365.9224.74.camel@rosella.wigram> (raw)
In-Reply-To: <1189024766.46df13fed404a@webmail.in-berlin.de>

On Wed, 2007-09-05 at 22:39 +0200, Oliver Bandel wrote:

> The behaviour of OCaml's
>   Filename.concat (Filename.dirname) (Filename.basename)
> makes sense to me. IMHO it should be done the way OCaml does it.

You fail to understand that this requirement is ALSO
met by Posix C functions and bash.

The difference is Ocaml's function doesn't have well specified
semantics, whereas Posix is an International Standard backed
by the United Nations.

The Ocaml manual says this:

http://caml.inria.fr/pub/docs/manual-ocaml/libref/Filename.html

"Moreover, after setting the current directory to dirname name (with
Sys.chdir), references to basename name (which is a relative file name)
designate the same file as name before the call to Sys.chdir.

And that is in fact rubbish: filename functionality is not
directly related to the filesystem, because the files need
not exist (or may not agree with the specified name in kind).

Other than this text, the Ocaml manual in fact does NOT
specify what happens if there is a trailing / character.

Posix does. So you're wrong on all counts here.
There's no excuse for Ocaml not doing one of:

	a) following the Posix rules on a Posix platform
	   AND saying so
	b) following other rules, AND describing them

In general, a WEAK specification is good, and the Ocaml
specification here is weak: it doesn't specify what happens
if there is a trailing / character. However in THIS case
the user may be surprised at what it actually does.

Indeed, the OP Eric was surprised!

The fact is I AGREE WITH YOUR ARGUMENT if you would be arguing
that it is sensible to consider that since in Unix you cannot
tell if a filename refers to a directory or a non-directory file,
a SENSIBLE CONVENTION is to put a / at the end if you mean a 
directory.

I agree, that's sensible. But it doesn't matter. The purpose
of the Filename module is to process filenames in a way that
closely matches the normal behaviour of native functions on
the native platform .. and the interpretation above IS NOT DOCUMENTED.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  parent reply	other threads:[~2007-09-06  4:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-05  8:45 Erik de Castro Lopo
2007-09-05 10:41 ` [Caml-list] " Richard Jones
2007-09-05 11:10   ` Erik de Castro Lopo
2007-09-05 11:25     ` Oliver Bandel
2007-09-05 12:00       ` Erik de Castro Lopo
2007-09-05 13:06         ` Markus E L
2007-09-05 20:39         ` Oliver Bandel
2007-09-05 21:03           ` Oliver Bandel
2007-09-06  4:52           ` skaller [this message]
2007-09-06  7:09             ` Christophe Raffalli
2007-09-06  9:51             ` Oliver Bandel
2007-09-06  9:32           ` Markus E L
2007-09-06 10:00             ` Oliver Bandel
2007-09-05 12:15       ` Mattias Engdegård
2007-09-05 20:54         ` Oliver Bandel
2007-09-05 12:37     ` Brian Hurt
2007-09-05 13:06     ` Markus E L
2007-09-05 12:10   ` Olivier Andrieu

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=1189054365.9224.74.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=oliver@first.in-berlin.de \
    /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).