Path as an object in std.path

Lars T. Kyllingstad public at kyllingen.net
Thu Jun 6 03:48:52 PDT 2013


On Thursday, 6 June 2013 at 10:32:36 UTC, Regan Heath wrote:
> On Thu, 06 Jun 2013 08:55:50 +0100, Lars T. Kyllingstad 
> <public at kyllingen.net> wrote:
>
>> 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:
>
> Does System.IO.DirectoryInfo:
> http://msdn.microsoft.com/en-us/library/system.io.directoryinfo.aspx
>
> Add sufficient value to justify it's existence to your mind?
>
> vs just having System.IO.Directory:
> http://msdn.microsoft.com/en-us/library/system.io.directory.aspx

They add great value, but that is a completely different 
discussion, as these are more similar to std.file.DirEntry.  The 
added value is mainly in the performance benefits; for example,

     if (exists(f) && isFile(f) && timeLastModified(f) < d) ...

requires three filesystem lookups (stat() calls), whereas

     auto de = dirEntry(f);
     if (de.exists && de.isFile && de.timeLastModified < d) ...

is just one.

I see no such benefit in the proposed Path type.


More information about the Digitalmars-d mailing list