[phobos] RFC: std.path

Lars Tandle Kyllingstad lars at kyllingen.net
Sun Jun 12 08:15:25 PDT 2011


On Sun, 2011-06-12 at 11:39 -0300, Jose Armando Garcia wrote:
> On Wed, Jun 8, 2011 at 4:29 PM, Lars Tandle Kyllingstad
> <lars at kyllingen.net> wrote:
> > As you may already know, I've had a new version of std.path in the works
> > for a while.  It is ready now, and I am waiting for my turn in the
> > review queue in the main NG.  In the meantime, I just thought I'd run it
> > by this mailing list to iron out the worst wrinkles.
> >
> > So, if you feel like it, please comment.
> >
> > Code:
> > https://github.com/kyllingstad/phobos/blob/std-path/std/path.d
> >
> > Docs:
> > http://www.kyllingen.net/code/new-std-path/phobos-prerelease/std_path.html
> >
> >
> > -Lars
> >
> 
> Looks good. Some minor comments:
> 
> 1) At many places, the code seems to be indexing into char and wchar
> arrays which have variable size encoding is this an oversight?

As long as you are searching for a specific character, and that
character only consists of one code unit, it is fine.  For instance, '/'
will never appear as the second, third or fourth code unit of any UTF-8
encoded character.


> 2) There is still some code that is not "templetized" and only accepts
> one parameter type. Was this on purpose?

It is on purpose, but it can of course be argued whether my reasons are
good enough. ;)  There are four functions which only accept UTF-8
strings:

- glob() (formerly fnmatch())
- expandTilde()

These functions are from the old std.path, and I haven't made any
changes to them in my version.

- toAbsolute()
- toCanonical()

These functions call std.file.getcwd(), which returns a char array.  If
you want any other width, some transcoding must happen, and that may as
well be up to the user.  (The same reasoning applies to expandTilde(),
by the way, as that uses the HOME environment variable, and environment
variables are assumed to be UTF-8 encoded in Phobos.)

-Lars



More information about the phobos mailing list