develooper Front page | perl.perl5.porters | Postings from September 2001

Re: [PATCH op.c op.h pp_sys.c t/op/local.t pod/perlfunc.pod] local chdir()

Thread Previous | Thread Next
Bryan C . Warnock
September 1, 2001 01:49
Re: [PATCH op.c op.h pp_sys.c t/op/local.t pod/perlfunc.pod] local chdir()
Message ID:
On Friday 31 August 2001 07:38 pm, Michael G Schwern wrote:
> Here it is.  A complete, documented C<local chdir($dir)> based on
> crab's code patch.
> I plan to do similar things to single-arg select() and umask().
> Scream now or forever hold your peace.

Are those the only two options?

I'm still not clear why you specifically want to introduce new grammar to 
implement this, as opposed to, say, the tied example provided earlier.

What are the advantages of having 'local' work with chdir(), compared to the 
disadvantages of having variable scope declarators that are no longer 
limited to variables, but now work with functions?  (Only, of course, not 
all functions, just a select few function.  And not all scope declarators, 
just 'local'. [1])

It seems, if you wanted to strive for consistency (which you are usually a 
champion of), you'd implement this by fixing the original inconsistency - 
having a description of a program's system state (in this case, the current 
working directory, although, as you mention, the umask would also be a good 
candidate) implemented by a magic global, instead of a function.  (Such as 
uid, gid, program name, etc.) [2]  Of course, we're a little short on 
punctuation characters, and $/, besides being taken, would be considered too 
Unix-centric for some folks.  

You could do $CWD, or some such, which is exactly what Abigail's solution 
provided (save a name change and the necessity to 'use').

[1] Of course, 'my' wouldn't make sense, and many of the globals can't be 
lexically scoped, either.

[2] And given [1], it would make it that much more consistent with the other 
program state variables.

Bryan C. Warnock

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About