[phobos] next release (meaning of path)

Jonathan M Davis jmdavisProg at gmx.com
Thu Sep 16 16:03:10 PDT 2010


On Thursday, September 16, 2010 04:27:17 SHOO wrote:
> (2010/09/16 0:45), Jonathan M Davis wrote:
> > On Wednesday 15 September 2010 05:06:58 SHOO wrote:
> >> I think that these features should be refined more, too. I am confused
> >> that the handling of strings and path are mixed.
> > 
> > A path _is_ a string. It's a string which indicates where on the file
> > system a file is located. All of the functions in std.path are,
> > therefore, string-related. However, they all relate to paths as opposed
> > to strings in general, so I don't see what's mixed about them.
> > 
> > - Jonathan M Davis
> 
> That is right.
> However, what about vice versa? string is not path in some cases.
> 
> For example, the thing which "exists" means may not be a file. (URL,
> ISBN, words, system specialized function, and so on. Strings may not
> show only a pass.)
> The thing which "join" connects may not be a pass. (You cannot guess
> result of join("path", "to", "the", "file") is "path/to/the/file" or
> "topaththepathfile". And this brings on conflict between std.string.join
> and std.path.join)
> You cannot be convinced that "getSize" is the capacity of the file. (It
> may be the allocated memory size or the NIL terminated string length.)
> 
> This is only a part of the examples.
> Users have wrong how to use if users will not treat it carefully.
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos

That sort of stuff stems from the fact that a path is not its own type. std.path 
contains functions for dealing with strings that are paths. If the strings that 
you give it aren't valid paths, then either they won't work or you won't get 
valid paths out of them (depending on the function and what it's doing). Sure, 
std.path.join() conflicts with std.string.join(), but they do different things, 
albeit similar.

Complaining about std.path using strings and that those strings may not be valid 
paths would be like complaining that std.xml uses strings and that those strings 
may not be valid xml. The functions are designed for handling strings that are 
paths, and at least some of them check that the strings they're given are valid 
paths.

I really don't understand what the problem is. std.path deals with strings that 
are paths. std.string deals with strings in general. And std.file deals with file 
operations. They are all quite distinct, even if some function names do overlap 
(which is one of the reasons that we have modules rather than a global 
namespace).

- Jonathan M Davis


More information about the phobos mailing list