Re: Unify cwd() [was: Re: $*CWD instead of chdir() and cwd()]

2005-04-21 Thread Larry Wall
On Thu, Apr 21, 2005 at 08:22:29AM +0200, Johan Vromans wrote: : >From the perspective of 'current directory' there should also be a : simple and elegant way that will do in most cases. Advanced tricks can : be made possible using separate modules and such. Yes, easy things should be easy, and har

Re: Unify cwd() [was: Re: $*CWD instead of chdir() and cwd()]

2005-04-21 Thread Juerd
Johan Vromans skribis 2005-04-21 8:22 (+0200): > This is exactly the point (I think) Schwern is trying to make. There > is 'open', that will do most of the time. If a novice user asks how to > open a file, you can say "Well, just 'open $fh, $file'". If you want > more than vanilla file access, th

Re: Unify cwd() [was: Re: $*CWD instead of chdir() and cwd()]

2005-04-21 Thread Johan Vromans
Chip Salzenberg <[EMAIL PROTECTED]> writes: > According to Michael G Schwern: >> 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. > > And there is more than one open. Perl does have f

Re: Unify cwd() [was: Re: $*CWD instead of chdir() and cwd()]

2005-04-16 Thread Dave Whipp
Chip Salzenberg wrote: As you know, under Unix, there's no such thing as "the current directory" as a string. The only durable current directory is the device and inode of C. It's not wise to conflate the current directory with a name that at some point in the past could have been used to reach i

Re: Unify cwd() [was: Re: $*CWD instead of chdir() and cwd()]

2005-04-16 Thread Chip Salzenberg
According to Michael G Schwern: > Yes, there are lots of ways to check the cwd each filling in one edge > case or another. However I'd like to believe its possible to come up with > one simple, safe cwd() that works for 99.9% of the cases and call that cwd(). Well, it's certainly possible ... and

Re: Unify cwd() [was: Re: $*CWD instead of chdir() and cwd()]

2005-04-16 Thread John Macdonald
On Saturday 16 April 2005 01:53, Michael G Schwern wrote: > How cwd() is implemented is not so important as what happens when it hits > an edge case. So maybe we can try to come up with a best fit cwd(). I'd > start by listing out the edge cases and what the possible behaviors are. > Maybe we

Re: Unify cwd() [was: Re: $*CWD instead of chdir() and cwd()]

2005-04-16 Thread Michael G Schwern
On Fri, Apr 15, 2005 at 09:32:23PM -0400, Chip Salzenberg wrote: > > Perl 6 is going to have to decide on some sort of standard internal getcwd > > technique, $CWD or not. > > I don't think Perl 6 "has" to do anything of the kind. It would > be a mistake to try. Sorry, I had assumed that having

Re: Unify cwd() [was: Re: $*CWD instead of chdir() and cwd()]

2005-04-16 Thread Chip Salzenberg
According to Michael G Schwern: > On Fri, Apr 15, 2005 at 08:31:57PM -0400, Chip Salzenberg wrote: > > There are several methods to determine the current directory. > > Perl 6 is going to have to decide on some sort of standard internal getcwd > technique, $CWD or not. I don't think Perl 6 "has"

Unify cwd() [was: Re: $*CWD instead of chdir() and cwd()]

2005-04-15 Thread Michael G Schwern
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

Re: $*CWD instead of chdir() and cwd()

2005-04-15 Thread Chip Salzenberg
According to chromatic: > On Fri, 2005-04-15 at 23:52 +0200, Juerd wrote: > > Well, after failure it can be cwd() but false without breaking any real > > code, because normally, you'd never if (cwd) { ... }, simply because > > there's ALWAYS a cwd. > > Not always -- try removing a directory that's

Re: $*CWD instead of chdir() and cwd()

2005-04-15 Thread Chip Salzenberg
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 corn

Re: $*CWD instead of chdir() and cwd()

2005-04-15 Thread Larry Wall
On Fri, Apr 15, 2005 at 03:22:48PM -0700, Michael G Schwern wrote: : On Fri, Apr 15, 2005 at 11:52:38PM +0200, Juerd wrote: : > > becomes an unverifiable operation. You have to use chdir() if you want to : > > error check and $CWD is reduced to a "scripting" feature. : > : > Well, after failure i

Re: $*CWD instead of chdir() and cwd()

2005-04-15 Thread Michael G Schwern
On Fri, Apr 15, 2005 at 11:52:38PM +0200, Juerd wrote: > > becomes an unverifiable operation. You have to use chdir() if you want to > > error check and $CWD is reduced to a "scripting" feature. > > Well, after failure it can be cwd() but false without breaking any real > code, because normally,

Re: $*CWD instead of chdir() and cwd()

2005-04-15 Thread Juerd
chromatic skribis 2005-04-15 15:18 (-0700): > > Well, after failure it can be cwd() but false without breaking any real > > code, because normally, you'd never if (cwd) { ... }, simply because > > there's ALWAYS a cwd. > Not always -- try removing a directory that's the pwd of another > process. R

Re: $*CWD instead of chdir() and cwd()

2005-04-15 Thread chromatic
On Fri, 2005-04-15 at 23:52 +0200, Juerd wrote: > Well, after failure it can be cwd() but false without breaking any real > code, because normally, you'd never if (cwd) { ... }, simply because > there's ALWAYS a cwd. Not always -- try removing a directory that's the pwd of another process. -- c

Re: $*CWD instead of chdir() and cwd()

2005-04-15 Thread Larry Wall
On Fri, Apr 15, 2005 at 01:12:46PM -0700, Michael G Schwern wrote: : Thus spake Larry Wall: : > 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.

Re: $*CWD instead of chdir() and cwd()

2005-04-15 Thread Juerd
Michael G Schwern skribis 2005-04-15 13:12 (-0700): > To be clear: Only the store operation will return undef on failure. > Additional fetches on $CWD will continue to return the cwd. Still breaks $ref = \($CWD = $foo); I'm not sure this breakage matters, but if it breaks one thing, it's

Re: $*CWD instead of chdir() and cwd()

2005-04-15 Thread Michael G Schwern
Thus spake Larry Wall: > 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

Re: $*CWD instead of chdir() and cwd()

2005-04-15 Thread Larry Wall
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 undefin