[phobos] std.path proof of concept

Lars Tandle Kyllingstad lars at kyllingen.net
Mon Apr 26 14:08:55 PDT 2010


On 04/26/2010 09:31 PM, Andrei Alexandrescu wrote:
> On 04/26/2010 01:10 PM, Ellery Newcomer wrote:
>> Andrei Alexandrescu<andrei at ...> writes:
>>> I looked at the design. It is very solid and elegant, but I suggest we
>>> save it for a different opportunity. Scenarios in which code running on
>>> a platform yet needs extensive functionality for the other are a tad
>>> tenuous.
>>>
>>
>> Part of the point of the path manipulation routines in dmdz.d was to
>> get around
>> the fact that dmd/windows doesn't have posix path manipulation.
>> Another part was
>> to convert from one to the other. I don't think such scenarios are
>> tenuous at
>> all. As far as abstractions are concerned, though, no idea.
>
> I see. But since zip files work on both Windows and Unix, there must be
> a common ground of functionality that works for both.

That's because any program/library that manipulates raw zip files on 
Windows must also have some POSIX path manipulation capabilities.  Right 
now, that's in Phobos, but it's hidden from the user.


> I'm hoping to
> insist on that instead of enacting a schism. After the schism, widening
> the incompatibilities will become the path of least resistance.

Are you envisioning a system that auto-detects whether something is a 
Windows or a POSIX path and converts it to some OS-agnostic internal 
representation?  E.g. something like

   // Auto-detect Windows path
   auto path = Path("c:\\foo\\bar.baz");

I don't think that will work, because the above is a perfectly valid 
POSIX path as well, except it's the name of a single file.  Just try typing

   touch 'c:\foo\bar.baz'

at a Linux command prompt.


The only other option I can see is to have std.path automatically work 
with Windows paths on Windows and POSIX paths on POSIX -- which is 
exactly what I'm suggesting.


Anyway, I'm not married to this idea, I just think it's a good one. ;)

I still think something needs to be done to std.path, though (and I'm 
still volunteering to do it).  Did any of my other suggestions seem 
worthwhile, or are people happy with the module the way it is?  Are 
there other suggestions?

-Lars


More information about the phobos mailing list