On Thursday, 6 June 2013 at 07:05:52 UTC, Lars T. Kyllingstad wrote:
On Wednesday, 5 June 2013 at 06:27:46 UTC, Dylan Knutson wrote:
Hello,
I'd like to open up the idea of Path being an object in std.path. I've submitted a pull (https://github.com/D-Programming-Language/phobos/pull/1333) that adds a Path struct to std.path, "which exposes a much more palatable interface to path string manipulation".

[...]

Let me add some more to this. To justify the addition of such a type, it needs to pull its own weight. For added value, it could do one or both of the following:

1. Maintain an isValidPath() invariant, for early error detection. (On POSIX, this is rather trivial, as any string that does not contain a null character is in principle a valid path, but on Windows, the situation is different.)

2. Add in-place versions of path modifiers (setExtension, setDrive, etc.), for improved performance.

One solution would be for Path to be a trivial string wrapper which does (1) and not (2). In this case, it is justified to have Path *in addition to* the existing functions.

Another solution would be for Path to do (2), possibly in addition to (1). However, in this case it should be a *replacement* for the existing functions, and not an addition. Otherwise, we have two almost-equal ways of doing the same thing, which should be avoided. (I am not advocating this, however, as it will massively break user code all over again.)

Lars

Reply via email to