On Wed, 19 Aug 2009, Darren Duncan wrote:

My proposal is to have all filesystem paths as seen within Perl being relative paths, and that there are multiple filesystem roots which can be referred to by name and each relative path is explicitly relative to a named root; each of these named roots is called a "directory of interest" or "doi".

I briefly mentioned a similar idea, but with no theoretical background :). I would've called them "bookmarks" instead of "doi", though.

For those who shied away from Darren's large theoretical background, fearing that it would lead to "pie-in-the-sky" or something, the simple version of his proposal was to have a magic global hash, and have it work like:

%*DOI<home> = "/home/foo";
$path = p{home/Music}; # $path points at /home/foo/Music

        I disagree with the syntax, but the idea has merit.

Your idea for making everything a relative path isn't one that appeal to me. But having a predefined set of bookmarks that could be used is certainly an interesting idea.

        I don't like your syntax, though :).  But see below.

 fsroot - the root of the real file system, analogous to "/"

I think we should stick with / as it's well-understood. Unless the Windows users among us see some advantage to fsroot -- I'd be happy to discuss it with them.

 fscwd - the dir that was the fs CWD when Perl started up

Stick with $*CWD for this, I reckon, and have it implicit in all paths that don't start with an absolute path. But all the other variables below should be absolute paths.

 docs - the dir that contains the usual files we want to work with
 temp - the dir where we can put temporary files
 home - the current user's home dir
 mycwd - some other cwd-dir, which is virtual-changeable in Perl

        Vote yes to temp and home.  Don't understand what you mean by "docs".

So to refer to common things on a Unix system like the fully-qualified ways, you can write paths like:

 fsroot/home/me/myfile
 fsroot/usr/bin/perl
 fsroot

        This is a great example of why fsroot is a bad idea.

For something analogous to traditional CWD sans modifications:

 fscwd/mynewfile.txt
 fscwd/lib/doit.pl

        ...and a great example of why fscwd is a bad idea.

To define a new doi at runtime, something like:

 %DOI{'mycwd'} = %DOI{'fscwd'};
 %DOI{'mycwd'} ~= 'subdir';
 # later
 my $fh = IO.open( 'mycwd/myfile.txt' );

        If I were doing it, I'd make it look like this:

%bookmark<mycwd> = $*CWD;
%bookmark<mycwd>.push('subdir');
# later
my $fh = IO.open( p{#mycwd#/myfile.txt} );

The only part I don't like is marking the "mycwd" with the hashes. I think we can't do without markers altogether because it would absolutely confuse everyone :). Putting a hash before and after is also a bad idea because it's like nothing else in Perl.

The only other idea I can think of is to come up with another quote adverb/pragma pair. Something like:

use hashinterpolate %*bookmark;

...and have the :hi (short for :hashinterpolate) quote modifier make $mycwd refer to %*bookmark<mycwd>, and then have :path automatically do :hi as well, unless :qq is used, or something.

Anyway, I home someone who knows more about Perl interpolation than me has an idea here.

Anyway, I like my terminology better, because it's less scary, and I've shaved off some of the scariest bits of syntax from your proposal, but there is still some work to be done on it here.

        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