On 12.08.2011 10:31, Jonathan M Davis wrote:
On Friday, August 12, 2011 10:14:11 Rainer Schuetze wrote:
- string absolutePath(string path, string base) returns an empty string
if path is empty. I would have expected that the base directory is
returned, so that you'll always get a sensible path.

Except, you gave it an invalid path if you gave it an empty string. Such a bug
would be found faster if you get an invalid path back than if you get the base
directory. I definitely think that if you give an invalid path to a function,
it's better to get an invalid path back out. Otherwise, it's just hiding bugs,
making them hard to catch and debug.

I don't have a very strong opinion on this, so I'm also fine with the current state. The use case I was thinking of was treating some user setting, where it might be bothersome to always specify "." instead of leaving a setting blank.

Also, when being used script like, it might be desirable to avoid the necessity for error handling to keep user code short by making best guesses at what the caller expects, as long as it is well-defined and in the documentation.

I know this is a little late, but speaking of invalid paths, a small addition to std.path could be a function to check whether a string is made up of valid path characters (as given in http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx for windows) and a function that converts/eliminates these characters from a path.

Reply via email to