Path as an object in std.path

Lars T. Kyllingstad public at kyllingen.net
Thu Jun 6 08:57:27 PDT 2013


On Thursday, 6 June 2013 at 15:41:51 UTC, Dylan Knutson wrote:
> FWIW, having Path be an object adds consistency with the rest 
> of Phobos, which has many entities which could be expressed as 
> primitives, expressed as objects. To name a few, DateTime is an 
> object, File is an object, and DirEntry is an object. Yes, they 
> could be described as integers, or a pointer, or a string, but 
> it's less cognitive load on the developer to recognize them as 
> separate types.

"Reducing cognitive load" is not the main reason these are 
objects.  DateTime lumps together no less than six integers.  
File adds automatic resource management via reference counting.  
DirEntry caches file information to avoid repeated filesystem 
lookups.  And so on.


More information about the Digitalmars-d mailing list