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
From:
Michael G Schwern
Date:
September 1, 2001 11:15
Subject:
Re: [PATCH op.c op.h pp_sys.c t/op/local.t pod/perlfunc.pod] local chdir()
Message ID:
20010901141548.D606@blackrider
On Sat, Sep 01, 2001 at 04:46:14AM -0400, Bryan C. Warnock wrote:
> 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.

Because, you have the weird caveat of having to keep the returned
variable around.

    use File::chdir;

    {
        my $old_dir = chdir($dir);
    }

The wires are showing through the magician's trick.


> 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?

That would be probably the best way to do it.  Have some sort of hook
that lets you add scope destructors to things.  I have no idea how to
do it.  Sounds complicated, <obvious troll>probably will never get
done.</obvious troll>


> 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.  

A)  I have no idea how to do that.
B)  More importantly, *that's* the sort of major redesign I'll leave for 
    Perl 6.

I don't want to redesign the language.  I just want to get some work
done.


-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <perl-qa@perl.org>	     Kwalitee Is Job One
Me? A robot? That's rediculous! For one thing, that doesn't compute at all!

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About