Discussion:
[Mason-devel] Mason 1.33 barring any objections?
Dave Rolsky
2006-05-21 15:13:01 UTC
Permalink
I'd like to release 1.33, as there are some important bug fixes in there,
notable one for the bug Shane McCarron just reported about <%filter>
basically preventing flush_buffer from working. Along the way, I found
other related bugs and added some tests for flushing and clearing the
buffer.

Here's the Changes file bits for 1.33

1.33

[ BUG FIXES ]

- If $m->flush_buffer() was called when there was a filter somewhere
in the component chain, the flush did nothing. Task id #596. Reported
by Shane McCarron.

- Added several tests for $m->flush_buffer() and $m->clear_buffer(),
which will hopefully avoid more bugs in this part of the code.

- On Win32, a test failed when Mason tried to use rename to move a dir
into an existing dir. Patch by Shane McCarron. Task id #594 and RT
#17828.

- Trying to load HTML::Mason::ApacheHandler outside of mod_perl caused
an error "like Undefined subroutine &Apache::perl_hook called at
/usr/local/share/perl/5.8.7/HTML/Mason/ApacheHandler.pm line
257". While it will never _run_ outside of mod_perl, it should at
least load.

- The example code in the HTML::Mason::Resolver::Null code was
just wrong. Fixed by John Siracusa.



-dave

/*===================================================
VegGuide.Org www.BookIRead.com
Your guide to all that's veg. My book blog
===================================================*/
jesse
2006-05-21 16:01:02 UTC
Permalink
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?

Best,
jesse
Dave Rolsky
2006-05-22 01:30:16 UTC
Permalink
Post by jesse
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.
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.

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


-dave

/*===================================================
VegGuide.Org www.BookIRead.com
Your guide to all that's veg. My book blog
===================================================*/
jesse
2006-05-22 01:35:02 UTC
Permalink
Post by Dave Rolsky
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.
What is the magical nature of defining a "sub _ {}" anyway? I can't find
any docs about this in the perlsub pod.
It's a namespace-buster. Audrey likes it a whole lot for localization.
IE, by defining it in my calling code, mason isn't getting what it
thinks it's getting there.
Post by Dave Rolsky
-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
_______________________________________________
Mason-devel mailing list
https://lists.sourceforge.net/lists/listinfo/mason-devel
--
Dave Rolsky
2006-05-22 04:22:06 UTC
Permalink
Post by Dave Rolsky
Post by jesse
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.
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?
Post by Dave Rolsky
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
===================================================*/
David Wheeler
2006-05-22 15:22:03 UTC
Permalink
Post by Dave Rolsky
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?
Probably not. Note that MJD changed things in HOP so that they don't
use _() as a custom function anymore. Here are his notes on the why
and wherefore of the change:

http://hop.perl.plover.com/errata/byid.cgi/131
http://hop.perl.plover.com/~alias/list.cgi?2:mss:264

Best,

David
David Wheeler
2006-05-22 15:24:07 UTC
Permalink
Post by David Wheeler
Probably not. Note that MJD changed things in HOP so that they
don't use _() as a custom function anymore. Here are his notes on
http://hop.perl.plover.com/errata/byid.cgi/131
http://hop.perl.plover.com/~alias/list.cgi?2:mss:264
If you want a "super-global" thingy, all
you have to do is use a name that starts with "::".
package A;
sub ::foo { ... }
package B;
if (::foo(...)) { ... } # Calls ::foo regardless of where it was
defined
package C;
if (::foo(...)) { ... } # Calls the same ::foo as the previous
package D;
sub ::foo { ... } # Compile-time subroutine redefinition warning
Alternatively, for variables, you can use the special ${^...}
package A;
${^Foo} = 1;
package B;
print ${^Foo}; # Prints 1
package C;
${^Foo} = 2;
package D;
print ${^Foo}; # Prints 2
Cheers,

David
jesse
2006-05-22 15:33:01 UTC
Permalink
And with that, I'll pipe down. Consider my request withdrawn.

David, thanks for the cluedump from Mark.
Dave, sorry for the distraction from getting the release out.
Audrey, looks like we need a new plan.

Jesse, who needed to put a phrase after the comma.
Benjamin Franz
2006-05-25 11:21:12 UTC
Permalink
Post by Dave Rolsky
*_ 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.
To put it mildly. It has been in the Perl core forever. Anyone who does
much file system stuff tends to use it heavily.
Post by Dave Rolsky
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.
You can already do this via the UNIVERSAL namespace if you use OO notation to invoke it.

#!/usr/bin/perl

use strict;
use warnings;

{
no warnings; # Just to quiet the 'used only once' warning
*UNIVERSAL::something = sub { print "hello\n" };
}

'random text'->something();

I think it is still probably a bad idea in code that goes into CPAN or
uses CPAN modules. You never know when you might collide with other
people's methods unless you namespace the function names via some hack
like 'masonunivseral_function()' - in which case why both monkeying around
with exotic hacks? Perl has a perfectly good namespace scheme already and
you can invoke things from another namespace the standard way:

Yourglobalnamespace::yourglobalfunction();
--
Benjamin Franz

I don't care how many levels of reality you posit; as soon as you posit even
one it's turtles all the way down.
---Nova Spivak
Loading...