Re: $*CWD and chdir()

2009-08-20 Thread Jon Lang
Martin D Kealey wrote: > I wonder if this is becoming the new Perl mantra "use lexically scoped > pragmata". Larry said it much more succinctly: all's fair if you predeclare. -- Jonathan "Dataweaver" Lang

Re: $*CWD and chdir()

2009-08-20 Thread Martin D Kealey
On Wed, 19 Aug 2009, Timothy S. Nelson wrote: > ..but Perl is more magic than bash :). Seriously, I can see both > sides of the argument, and I'm leaning towards the $*CWD = chdir idea (as an > option if people want to use it), but I realise that a lot of people are > leaning the other way.

Re: $*CWD and chdir()

2009-08-19 Thread Darren Duncan
Mark J. Reed wrote: On Wed, Aug 19, 2009 at 2:35 AM, Darren Duncan wrote: (If Perl really must have the ability to change the non-virtual "current working directory", such as because its going to spawn another non-Perl process, then this should use some separate mechanism to what all of Perl's o

Re: $*CWD and chdir()

2009-08-19 Thread Mark J. Reed
On Wed, Aug 19, 2009 at 2:35 AM, Darren Duncan wrote: > Having read all of this thread to date, I'll state a solution which should > be elegant and which I'm not sure has been stated yet. I think that's basically what we were suggesting above, except: > (If Perl really must have the ability to

Re: $*CWD and chdir()

2009-08-18 Thread Darren Duncan
Having read all of this thread to date, I'll state a solution which should be elegant and which I'm not sure has been stated yet. I propose that the concept of "current working directory" in Perl be a completely internal, virtual concept, and each Perl thread has its own "current working direc

Re: $*CWD and chdir()

2009-08-18 Thread Jon Lang
On Tue, Aug 18, 2009 at 7:03 PM, Mark J. Reed wrote: > The OS-level chdir() and getcwd() are not thread-safe. The usual > advice is to ignore them completely in multithreaded programs, in > favor of absolute paths (or relative paths from a fixed location, > never calling chdir()).  This is part of

Re: $*CWD and chdir()

2009-08-18 Thread Mark J. Reed
The OS-level chdir() and getcwd() are not thread-safe. The usual advice is to ignore them completely in multithreaded programs, in favor of absolute paths (or relative paths from a fixed location, never calling chdir()). This is part of the a reason that Apache2 recommends fastcgi for non-prefork

Re: $*CWD and chdir()

2009-08-18 Thread Timothy S. Nelson
Ok, here's a fairly significant point posted on IRC. wayland76: the point of using $*CWD would be (and would *have* to be, given how context vars work) to give each thread its own working directory, independent of the process as a whole Now, given that chdir is an OS concept that a

Re: $*CWD and chdir()

2009-08-18 Thread Mark J. Reed
On Tue, Aug 18, 2009 at 10:37 AM, Jan Ingvoldstad wrote: >> It's not that unreasonable. > > I disagree, and I think I've explained why, and perhaps we won't get much > further. I'm not claiming that it's a good idea for bash to adopt this behavior, only that it's a reasonable expectation tohave up

Re: $*CWD and chdir()

2009-08-18 Thread Carlin Bingham
2009/8/19 Timothy S. Nelson : > >        Ok, so suppose we only allowed direct assignment to absolute paths? > That would be currently how it works. -- Carlin

Re: $*CWD and chdir()

2009-08-18 Thread Jan Ingvoldstad
On Tue, Aug 18, 2009 at 3:52 PM, Mark J. Reed wrote: > On Tue, Aug 18, 2009 at 9:26 AM, Jan Ingvoldstad > wrote: > > You think it's a bug that PWD="/etc" doesn't change your working > directory > > to /etc in bash? > > > > Please tell me you're joking. > > It's not that unreasonable. I disagree

Re: $*CWD and chdir()

2009-08-18 Thread Mark J. Reed
On Tue, Aug 18, 2009 at 10:26 AM, Timothy S. Nelson wrote: >        Ok, so suppose we only allowed direct assignment to absolute paths? Is there an echo in here? :) -- Mark J. Reed

Re: $*CWD and chdir()

2009-08-18 Thread Timothy S. Nelson
On Wed, 19 Aug 2009, Carlin Bingham wrote: 2009/8/19 Timothy S. Nelson :        So, if P5 does it for some global (note: global != environment) variables, then why not do it for some in P6? Because if (for some reason) I do: $> = 5; # Which calls setuid(5); print $>; # 5 Whereas: $*CWD =

Re: $*CWD and chdir()

2009-08-18 Thread Carlin Bingham
2009/8/19 Timothy S. Nelson : > >        So, if P5 does it for some global (note: global != environment) > variables, then why not do it for some in P6? > Because if (for some reason) I do: $> = 5; # Which calls setuid(5); print $>; # 5 Whereas: $*CWD = '..'; # which hypothetically calls chdir

Re: $*CWD and chdir()

2009-08-18 Thread Timothy S. Nelson
On Tue, 18 Aug 2009, Jan Ingvoldstad wrote: On Tue, Aug 18, 2009 at 2:33 PM, David Green wrote: Huh. Thank you, I did not know that. It makes "sense" (in that I understand what's going on now that I see it, and indeed it seems almost obvious), but I certainly couldn't call it "expected" be

Re: $*CWD and chdir()

2009-08-18 Thread Mark J. Reed
On Tue, Aug 18, 2009 at 9:26 AM, Jan Ingvoldstad wrote: > You think it's a bug that PWD="/etc" doesn't change your working directory > to /etc in bash? > > Please tell me you're joking. It's not that unreasonable. Given a variable that magically changes depending on your working directory, having

Re: $*CWD and chdir()

2009-08-18 Thread Jan Ingvoldstad
On Tue, Aug 18, 2009 at 2:33 PM, David Green wrote: > > Huh. Thank you, I did not know that. It makes "sense" (in that I > understand what's going on now that I see it, and indeed it seems almost > obvious), but I certainly couldn't call it "expected" because I didn't. And > I can guarantee I'

Re: $*CWD and chdir()

2009-08-18 Thread David Green
On 2009-Aug-18, at 5:48 am, Jan Ingvoldstad wrote: On Tue, Aug 18, 2009 at 1:02 PM, David Green wrote: It doesn't seem that surprising to me, especially after seeing the docs the first time. Are there environments where you can set a variable like $*CWD and it doesn't do something like chdi

Re: $*CWD and chdir()

2009-08-18 Thread Mark J. Reed
Er, that "basename" down there should be a "dirname", for those playing along at home. Memo to self: do not type long screeds on Blackberry... On 8/18/09, Mark J. Reed wrote: > It would be nice if the bikeshed had aluminum siding. Er, I mean, if > chdir() changed *CWD and vice-versa, though I'

Re: $*CWD and chdir()

2009-08-18 Thread Mark J. Reed
It would be nice if the bikeshed had aluminum siding. Er, I mean, if chdir() changed *CWD and vice-versa, though I'm not sure offhand how best to code that in idiomatic P6 to avoid the infinite recursion. Anyway, at the very least, a readonly *CWD holding a cached idea of the current dir is good.

Re: $*CWD and chdir()

2009-08-18 Thread Jan Ingvoldstad
On Tue, Aug 18, 2009 at 1:02 PM, David Green wrote: > On 2009-Aug-18, at 3:12 am, Jan Ingvoldstad wrote: >> >> It may seem cool, but I don't like secondary effects like that. They break >> the principle of least surprise. > > It doesn't seem that surprising to me, especially after seeing the docs t

Re: $*CWD and chdir()

2009-08-18 Thread David Green
On 2009-Aug-18, at 4:59 am, Carlin Bingham wrote: 2009/8/18 Timothy S. Nelson : It's not in the revised spec, but I think that, even though we've revived chdir, we should still have it so that changing $*CWD will do a chdir under the hood. While in the spirit of TIMTOWTDI, having a "

Re: $*CWD and chdir()

2009-08-18 Thread Carlin Bingham
2009/8/18 David Green : > On 2009-Aug-18, at 3:27 am, Timothy S. Nelson wrote: >> >> On Tue, 18 Aug 2009, David Green wrote: >>> > or however that would work in P6.  It may have problems, but by definition > they're the same problems as chdir() has.  What am I missing? > > chdir is a familar funct

$*CWD and chdir()

2009-08-18 Thread David Green
On 2009-Aug-18, at 3:27 am, Timothy S. Nelson wrote: On Tue, 18 Aug 2009, David Green wrote: Maybe setting $*CWD just calls chdir() under the hood? Same implementation, brand new shiny Perl-style interface! That was my intent, but we had some discussions on IRC about the whys and wherefores