[phobos] std.path proof of concept

Andrei Alexandrescu andrei at erdani.com
Mon Apr 26 01:21:51 PDT 2010


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.

Andrei

On 04/26/2010 03:01 AM, Lars Tandle Kyllingstad wrote:
> On 04/23/2010 05:26 PM, Andrei Alexandrescu wrote:
>> On 04/23/2010 10:23 AM, Steve Schveighoffer wrote:
>>> I would make a suggestion that the Windows version allows forward
>>> slash for a dir separator as input. "C:/foo/bar.txt" and
>>> "C:\\foo/bar.txt" are both valid paths on Windows.
>>
>> Makes sense. On an overall note, without having much time to look into
>> this, I wish very strongly we strive to define OS-independent path
>> abstractions before defining OS-dependent ones. Once the Windows vs.
>> Posix breach is in, it'll only grow larger because it requires less
>> design to put stuff in there.
>
> I think I may be explaining myself a bit badly here, so please allow me
> to clarify:
>
> For the most part, I want std.path to work *just as it does now*.
>
> If you call doStuffWith(path) on POSIX, it does stuff in the POSIX way,
> and if you call it on Windows, it does stuff in the Windows way. Code
> using it will automatically work on both platforms.
>
> The only difference will be that if you for some reason need to
> manipulate non-native paths, you will be allowed to do so by adding a
> prefix to your functions, e.g. Path!posix.doStuffWith(path).
>
>
> Rationale:
>
> * The code is already in Phobos, it's just string manipulation
> and doesn't require any special OS support, and there is
> thus *no need* to hide it from the user inside version(OS)
> blocks.
>
> * Handling non-native paths is not an obscure need. Examples
> include:
> - FTP and similar
> - Archive manipulation (for instance, the ZIP format uses
> POSIX paths internally)
>
> I'd argue that this doesn't introduce more of a Windows/POSIX breach
> than there already is in Phobos. I mean, in principle there is nothing
> preventing you from adding OS-specific stuff to std.stdio except common
> sense, and it will be the same here.
>
> -Lars
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos


More information about the phobos mailing list