Ok, here's a fairly significant point posted on IRC.

<TimToady> 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 applies to the process as a whole, rather than individual threads, but $*CWD is designed for individual threads, that pretty much means that it is a really bad idea to have $*CWD do chdir() for us.

Now, having said that, I think the idea of a per-thread CWD is a great idea, and I'd be in favour of using $*CWD over whatever getcwd retrns in Perl6 as much as possible. So I think it would be cool if all relative paths specified via p{} were relative to $*CWD, not getcwd(). So something like this:

        $*CWD = "/home/username";
        $path = p{Music};
        say $path.canonpath();
        # prints "/home/username/Music"

        My question is, what else uses chdir/getcwd style paths?  I know

qqx/$cmd @args[]/

...will pass its current dir to the child. Maybe we could have Perl6 do something like this pseudocode "under the hood" when someone does a qqx.

olddir = getcwd();
exec(qqx string here);

That would mean that $*CWD would effectively act as a per-thread working directory.

No doubt someone will write in and tell me how bad an idea this is. I look forward to having my ignorance exposed :).

| Name: Tim Nelson                 | Because the Creator is,        |
| E-mail: wayl...@wayland.id.au    | I am                           |

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-

Reply via email to