Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Oliver Bandel <oliver@first.in-berlin.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Bug in Filename.basename?
Date: Wed,  5 Sep 2007 22:54:19 +0200	[thread overview]
Message-ID: <1189025659.46df177b073a6@webmail.in-berlin.de> (raw)
In-Reply-To: <200709051215.l85CFqI31114@virtutech.se>

Zitat von Mattias Engdegå   rd <mattias@virtutech.se>:

> >Looking at that documentation, I can't see no bug in the implementation.
>
> As an extra data point, Python's os.path.basename("a/b/c/") returns "".
> It is defined to return "the final component of a pathname".
[...]

Using a perspective of view, based on string-handling, this might
be a good way (to use "").

But an empty string makes no sense, when it is interpreted as
part of a path. But "." makes sense in a path, and it refers to the
current directory. In the context of Filename,dirname and Filename.basename
this means, that if you give a directory-name, you have the basename
also indicating that it is a directory: the directory, which's
name can be find out by Filename.dirname.

==================================================
# let f n = (Filename.dirname n , Filename.basename n);;
val f : string -> string * string = <fun>
# f "/usr/lib";;
- : string * string = ("/usr", "lib")
# f "/usr/lib/";;
- : string * string = ("/usr/lib", ".")
# f "usr/lib";;
- : string * string = ("usr", "lib")
# f "usr/lib/";;
- : string * string = ("usr/lib", ".")
#
==================================================

So, the "." always make sense, but the empty string does not.
The file "." is not a regular file, it is the current dir,
which also is a file, but of different type than regular files or sockets...


>
> Python's basename/dirname pair have the same concatenative properties
> as O'Caml's so this makes sense in both languages.

OK, but the contents of "" can't be shown.
It's not a regular file and not a directory.

"." means a file of type directory (the current one), and that makes sense.
So "/usr/." makes sense.


>
> This is probably also more useful than the semantics of basename(1).
>


Yes.

Ciao,
   Oliver


  reply	other threads:[~2007-09-05 20:54 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
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 [this message]
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=1189025659.46df177b073a6@webmail.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --cc=caml-list@inria.fr \
    /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