On Fri, Apr 15, 2005 at 08:31:57PM -0400, Chip Salzenberg wrote:
> According to Michael G Schwern:
> > And this is exactly what File::chdir does.  $CWD is a tied scalar.
> 
> I don't think current directory maps well on a variable.  That won't
> stop people from using it, of course.  :-(
> 
> There are several methods to determine the current directory.  Each
> one has its corner cases, strengths and weaknesses (thus the
> proliferation of Cwd module functions), and it doesn't make any sense
> to me to elevate one over the rest through the proposed $CWD.

This is orthoginal to $CWD.  

Perl 6 is going to have to decide on some sort of standard internal getcwd 
technique, $CWD or not.  In the same way that we have open() not fopen, 
fdopen, freopen... we can choose the safest and most sensible technique for 
determining the cwd and use that.  You have to because when a new user asks 
"how do I get the current working directory?" you want to say "cwd()" and 
not "Well, there are a variety of different techniques..."  Cwd.pm is a 
perfect example of this problem.  Which one should a user use?  Most folks 
just won't care and the micro-differences between the functions in Cwd.pm
aren't worth the trouble.  

Present a sensible default.  Write a module with all the other options for 
those who need it.


>       mkdir '/tmp/foo';
>       $CWD = '/tmp/foo';
>       rename '../foo', '../bar';
>       say $CWD;  # Well?  Which is it?

Its exactly the same as...

        mkdir '/tmp/foo';
        chdir '/tmp/foo';
        rename '../foo', '../bar';
        say cwd();

Reply via email to