> On 3 Jan 2017, at 06:58, Joachim Durchholz <j...@durchholz.org> wrote:
> Yes, chdir is nasty because it's a global setting and you never know which of 
> the functions you're calling might be changing the setting.
> 
> indir solves all these things. (Provided it changes the current directory 
> back even in the face of exceptions.)

Please note that there is no real chdir() at the OS level, because that is a 
bad idea in a threaded environment.  And for that reason, the JVM doesn’t allow 
for it, afaik, and thus it wouldn’t work on the JVM backend anyway.

The “current directory” is represented by the $*CWD dynamic variable.  Changing 
the “current directory” in a scope, is nothing else than syntactic sugar around 
creating a local lexical $*CWD.  By virtue of the destruction of lexical 
variables when they go out of scope, this will also work if the scope is exited 
by an exception.


>> 4) The topic of this ticket: its default set of tests for the directory will 
>> change (just test if it's a directory?)
> Some platform might even be okay with a nondirectory for chdir. This wouldn't 
> be particularly useful, but we can't assume that all platforms do only useful 
> things.
> 
> That said, I think the indir tests should just test that chdir is being 
> called at the right times with the right arguments (can Perl6 tests do 
> mocking? that would be needed)
> So any error case testing can be done for chdir.

Since changing the current directory is nothing else than changing $*CWD, 
mocking should not be a problem.


>> Not every change will be possible, because we can't break existing spectests,
> Oh, is Perl6 that stable now?
> I thought it should still be possible to fix mistakes.

I hear they’re still fixing mistakes in Perl 5.  Which, in my impression, is 
considered stable by many  :-)


Liz

Reply via email to