Re: Mason 1.33 barring any objections?

Dave Rolsky <[email protected]> Mon, 22 May 2006 01:21:43 -0500 (CDT)
Newsgroups gmane.comp.web.mason.devel
Message-ID <[email protected]>
On Mon, 22 May 2006, Audrey Tang wrote:

> 2006/5/22, Dave Rolsky <[email protected]>:
>> 
>> On Sun, 21 May 2006, jesse wrote:
>> 
>> > I've actually got one minor thing I'd been meaning to ask about. It's
>> > not serious enough to hold up 1.33, but it'd make me a happy camper to
>> > fix it.
>> >
>> > Lines 98-101 or so of Mason/Compiler/ToObject.pm read:
>> >
>> >    if (defined $file && !-f $file) {
>> >            my ($dirname) = dirname($file);
>> >                   if (!-d $dirname) {
>> >                       unlink($dirname) if (-e _);
>> >
>> >
>> > Because of the magical nature of sub _ {}, this causes weird
>> > behaviour when another module defines a sub _.  Is there any particular
>> > reason that code is as it is?
>> 
>> Well, the usual reason for using "_" like that is that it's faster because
>> it saves a stat() call. I've gotten in the habit of just using whenever i
>> can, for one.
>
> Er, in that case, why even test for -e?  The call to unlink() can fail with
> no punity even if $dirname is nonexistent.

Ok, regardless of the weirdness of the particular code in question here, 
do you seriously expect that Mason, and all the code Mason depends on, 
will not use _ with filetest/stat/etc anywhere?

>> What is the magical nature of defining a "sub _ {}" anyway? I can't find
>> any docs about this in the perlsub pod.
>
> *_ is global to all packages.

Patient: Doctor, it hurts when I point the barrel at my head and pull the 
trigger.
Doctor: Uh ...

The use of _ for filetest and stat is well-documented, and probably in use 
in lots of code on CPAN and elsewhere.

I can see the use of a "super-global" function, but it rather than using 
*_, which is clearly broken, it might make sense to try to get something 
into the Perl core to really support this, like a special namepsace or 
something like that.


-dave

/*===================================================
VegGuide.Org                        www.BookIRead.com
Your guide to all that's veg.       My book blog
===================================================*/


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642