On Fri, 15 Jul 2011 15:21:49 -0400, Nick Sabalausky <[email protected]> wrote:

"Lars T. Kyllingstad" <[email protected]> wrote in message
news:[email protected]...
On Fri, 15 Jul 2011 02:45:02 +0200, Andrej Mitrovic wrote:

All functions have nice names except fcmp, why the abbreviation?

For consistency with std.algorithm.cmp and std.string.icmp, on which it
is based. I'd be open for other suggestions if people think it should be
changed.


I'm happy with it having the obscure name "fcmp" because *all* it is is
either a case-insensitive or case-sensitive string comparison, and I think
it's dangerous to blindly use that to compare filepaths. If it were named
something like "filePathCompare", then people would get a nastly surprise
when this returned false instead of true:

filePathCompare(r"C:\dir\file.txt", r"C:\dir/foo\..\file.txt");

I can't imagine getting false from that would ever be desirable.

This is a big part of why I think we need a canonical() function (although
maybe a more like "canonicalPath" for the same reason that we have
"joinPath" instead of "join").


Is expandTilde supposed to work on Windows? I've never seen tilde used
there.

Nope, as specified in the docs it is a no-op on Windows.  As Nick points
out, it is not obvious what is the correct "home directory" on Windows.
Moreover, and perhaps even more importantly, there is no precedence for
the tilde character to mean "home directory" on Windows at all.


Actually, if Windows did have one single equivalent to "/home/{user}", then I think it would be absolutely fantastic to make tilde mean "home directory"
on Windows. But as things are, that's a moot point, of course.

The typical thing is to use the environment variable USERPROFILE, but that's an odd dependency for a string processing library. Windows also doesn't keep the same notion of home directory as Unix does. You can read more about it here: http://en.wikipedia.org/wiki/Environment_variable

If that's the only function that uses environment variables, and you can't have the function without it, it might be worth having it. However, we must think about how that affects things like purity.

-Steve

Reply via email to