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

Nick Sabalausky a at a.a
Tue Mar 1 04:48:56 PST 2011


"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.)




More information about the Digitalmars-d mailing list