Re: Mason 1.33 barring any objections?

Benjamin Franz <[email protected]> Thu, 25 May 2006 06:20:42 -0700 (PDT)
Newsgroups gmane.comp.web.mason.devel
Message-ID <[email protected]>
On Mon, 22 May 2006, Dave Rolsky wrote:

> On Mon, 22 May 2006, Audrey Tang wrote:
>> 
>> *_ 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.

> 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



-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642