On Tue, 18 Aug 2009, Troels Liebe Bentsen wrote:

Glob's are special and should properly have it's own sub format, the problem of
including * and ? in Path's is that on Unix this is a allowed file system name.

Agreed about the subformat, but I think the "glob" function is sufficient in this case. I mean, I can think of a number of other sublanguages that could be given their own quoting format (sprintf, pack/unpack, Form.pm), but I don't think it's a good idea giving everything its own format -- I'd be happy to keep glob as just a function.

Urls could also be support with:

my Path $path = p:url{file:///home/test.file}

I would be very careful here, in that I wouldn't want to open the can
of worms inherent in non-file protocols (e.g., ftp, http, gopher,
mail), or even in file protocols with hosts other than localhost.

You are properly right, but then again if it's not up to Path to actual know
how to open or work with the file/url. It would only have to know the rules for
how urls work not how to open them. In it's basic form Path should not be able
to do any IO.

But I'm not too sure URL's belong in Path.

That's why we have the %*PROTOCOLS global variable, so that we can figure out what to do with the various protocols.

** Utility functions **

Path in itself knows nothing about the filesystem and files but might have a
peek in $*CWD to do some path logic. Except for that a number of File related
functions might be available to make it easy to open and slurp a file a Path
points to.

my File $file = p{/etc/passwd}.open;
if($file.type ~~ 'text/plain') {
 say "looks like a password file";
}

my @passwd = p{/etc/passwd}.lines;


if(p{/etc/passwd}.exists) {
 say "passwd file exists";
}

As soon as you allow methods such as .exists, it undermines your claim
that Path knows nothing about the file system or files.  IMHO, you
should still include such methods.

I don't know if I mentioned it, but I claim that the Path should also handle metadata as well as the actual path logic.

        HTH,


---------------------------------------------------------------------
| Name: Tim Nelson                 | Because the Creator is,        |
| E-mail: wayl...@wayland.id.au    | I am                           |
---------------------------------------------------------------------

----BEGIN GEEK CODE BLOCK----
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-
-----END GEEK CODE BLOCK-----

Reply via email to