std.path.getName(): Screwy by design?

Nick Sabalausky a at a.a
Tue Mar 1 05:26:47 PST 2011


"Lars T. Kyllingstad" <public at kyllingen.NOSPAMnet> wrote in message 
news:ikir9v$14ci$1 at digitalmars.com...
> On Tue, 01 Mar 2011 07:48:56 -0500, Nick Sabalausky wrote:
>
>> "Lars T. Kyllingstad" <public at kyllingen.NOSPAMnet> wrote in message
>> news:ikiktf$2vba$3 at digitalmars.com...
>>>
>>> I would like to say, however, that I think 'sep' is almost up there
>>> with rel2abs in terms of bad naming.  If you just see 'sep' in a piece
>>> of code, maybe you understand it is a separator, but I don't think
>>> everyone will conclude it is a directory separator.  Using the fully
>>> qualified name 'std.path.sep' isn't good either, because now it looks
>>> like it's a path separator.
>>>
>>>
>> Speaking of sep, I've never been entirely happy with std.path's tendency
>> to encourage the use of platform-specific directory separators. Windows
>> generally handles forward-slash just fine, so I've always felt it best
>> to always just use forward-slash, and then convert to backslash
>> as-needed in the very rare cases where it actually matters.
>>
>> Doing either std.path.join("..", "dir", "subdir", "file") or
>> ".."~sep~"dir"~sep~"subdir"~sep~"file" is fucking butt-ugly, and it's
>> useless anyway since "../dir/subdir/file" works just fine on all OSes
>> including Windows. (Obviously sep should still exist, regardless of what
>> it's named. But, at least judging by the docs, std.path just seems to
>> rely on it too much.)
>
> This was discussed on the Phobos mailing list a while ago, and Walter
> said that using forward-slash often doesn't work on Windows:
>
>  http://lists.puremagic.com/pipermail/phobos/2010-April/000309.html
>
> I don't use Windows much myself, so I don't know.
>

*shrug* The only problems I've ever had with forward-slash on Windows is 
with cmd.exe and some of the old-school MS-DOS cmdline apps. At the very 
least, all the stuff in std.file (and Tango, for that matter) handles 
forward slashes just fine. I suppose there might be some MS APIs that expect 
a backslash, but I'm still convinced that should be handled as close to the 
"must be backslash" point as possible rather than needlessly infecting *all* 
path-handling code.




More information about the Digitalmars-d mailing list