On Fri, Apr 15, 2005 at 03:11:59AM -0700, Michael G Schwern wrote:
: Error handling is simple, a failed chdir returns undef and sets errno.
: 
:       $CWD = $dir err die "Can't chdir to $dir: $!";

Offhand, I guess my main semantic problem with it is that if a chdir
fails, you aren't in an undefined location, which the new value of $CWD
would seem to indicate.  You're just where you were.  Then the user
either has to remember that, or there still has to be some other
means of finding out the real location.

The other problem with it is the fact that people will assign relative
paths to it and expect to get the relative path back out instead
of the absolute path.

: I encourage Perl 6 to adapt $*CWD similar to File::chdir and simply eliminate
: chdir() and cwd().  They're just an unlocalizable store and fetch for global
: data.

Your assumption there is a bit inaccurate--in P6 you are allowed to
temporize (localize) the effects of functions and methods that are
prepared to deal with it.  However, I agree that it's nice to have an
easily interpolatable value.  So I think I'd rather see $CWD always
return the current absolute path even after failure, and

    temp chdir($dir) err fail "Can't chdir to $dir: $!";

be made to work as a temporizable function at some point, via the TEMP
mechanism described in A4.

Larry

Reply via email to