Proposal for std.path replacement

Jonathan M Davis jmdavisProg at gmx.com
Thu Mar 3 10:52:18 PST 2011


On Thursday, March 03, 2011 10:31:20 Jerry Quinn wrote:
> Lars T. Kyllingstad Wrote:
> > As mentioned in the "std.path.getName(): Screwy by design?" thread, I
> > started working on a rewrite of std.path a long time ago, but I got
> > sidetracked by other things.  The recent discussion got me working on it
> > again, and it turned out there wasn't that much left to be done.
> > 
> > So here it is, please comment:
> >     http://kyllingen.net/code/ltk/doc/path.html
> >     https://github.com/kyllingstad/ltk/blob/master/ltk/path.d
> 
> Rather than:
> 
> drive() & stripDrive()
> extension() & stripExtension()
> 
> would it make sense to combine them?
> 
> string[2] splitDrive(path)
> string[2] splitExtension(path)

Those might not be bad functions to have, but they could get _really_ annoying 
if they were there _instead_ of the split functions. I, for one, am very likely 
to calling functions like stripExtension and passing the result directly into 
another function or using it directly in an expression. Having to throw a [0] or 
[1] on the end of all those calls would be ugly and error-prone (since it would 
be really easy to use the wrong index) - not to mention, it would be less 
efficient, which could matter in cases where you have to process a lot of file 
names.

So, they might not be bad functions to add, but I certainly wouldn't want to see 
them replace the strip functions.

- Jonathan M Davis


More information about the Digitalmars-d mailing list