Path as an object in std.path

Walter Bright newshound2 at digitalmars.com
Thu Jun 6 10:41:36 PDT 2013


On 6/6/2013 8:57 AM, Lars T. Kyllingstad wrote:
> 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.

It's hard to see what value there is in a type that is simply a wrapper around 
an existing type, and which provides implicit conversions too/from that existing 
type so that they can be intermixed arbitrarily.

At the end, that's nothing more than:

    alias string Path;


More information about the Digitalmars-d mailing list