Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.
While digging around in the debugger, I came across a method on a an object that I wasn't expecting to see. So I ack'd for it.
$ ack -a 'a_sub_not_likely_to_be_here' deps
deps/lib/perl5/Set/Scalar/Base.pm
20: eval 'sub UNIVERSAL::a_sub_not_likely_to_be_here { ref($_[0]) }';
24: ? eval { $_[0]->a_sub_not_likely_to_be_here }
deps/lib/perl5/JSON/PP.pm
1285: eval 'sub UNIVERSAL::a_sub_not_likely_to_be_here { ref($_[0]) }';
1288: ref($_[0]) ? eval { $_[0]->a_sub_not_likely_to_be_here } : undef;
deps/lib/perl5/Mouse/Util.pm
14: *UNIVERSAL::a_sub_not_likely_to_be_here = sub {
30: ? eval { $_[0]->a_sub_not_likely_to_be_here }
53: eval { $r->a_sub_not_likely_to_be_here; 1 }
deps/lib/perl5/Mouse/Tiny.pm
32: *UNIVERSAL::a_sub_not_likely_to_be_here = sub {
48: ? eval { $_[0]->a_sub_not_likely_to_be_here }
71: eval { $r->a_sub_not_likely_to_be_here; 1 }
Why do four different modules do this?
Mouse and Mouse::Tiny (Score:1)
Mouse (and thus Mouse::Tiny, which is a one-file concatenation of the Mouse libraries) use this because Scalar::Util's pure-perl version does, to emulate Scalar::Util::blessed without XS.
More recent versions of Mouse have removed this bit of code, deciding that (at least for now), if you want 5.6 you get a dependency on Scalar::Util.
I'm being evil (Score:2)
I've got a bloody good mind to write Break::Mouse which will delete that subroutine if it ever spots that it's been created. And load it into my CPAN-testing machines.
This shows why monkey-patching is generally a bad idea.
package Break::Mouse;
use Time::HiRes qw(setitimer ITIMER_VIRTUAL);
setitimer(ITIMER_VIRTUAL, 1, 1);
$SIG{VTALRM} = sub {
eval 'sub UNIVERSAL::a_sub_not_likely_to_be_here { die("Monkey-patching is bad\n")';
}
Re: (Score:1)
Evil indeed.
So how do we implement blessed without XS? As I said in a sibling comment, Mouse doesn't do this any more, it now just depends on Scalar::Util. But since I just took the code from Scalar::Util, so your package should be named Break::Scalar::Util.
Re: (Score:2)
Check to see if it's a reference and *isn't* a reference to a scalar/array/hash/sub etc. The list of magic values returned by
ref()for all the built-in types is inperldoc -f ref.Re: (Score:1)
Re: (Score:1)
UNIVERSAL::can( $foo, 'can' )Re: (Score:1)
Re: (Score:1)
Repo URL (Github preferred)? Email address?
Re: (Score:1)
Re: (Score:1)
Ah.
Re: (Score:1)
Wow, thats a loooong way to go to prove a point! (especially since the point it no longer valid (see Sartak's response below)).
Not to mention the fact that it is a generally bad idea since it will break Scalar::Util (and Mouse too) which is a core module, therefore resulting in a whole lot of false negatives from your CPAN testing machines.
While I normally agree with you that monkeypatching is an evil practice, like all evil practices there are some exceptions. In this case what Sartak was doing in Mou
Re: (Score:2)
Re: (Score:1)
I don't find threats funny, ... and neither does the Dept. of Homeland Security!!!
YOU ARE NOW ON THE WATCH LIST!!!!!!!! :P
Re: (Score:1)
Alternately, you could target only sane and modern versions of Perl, in the theory that anyone knowledgeable enough to use Mouse or Moose should be able to rely on a Perl version released this millennium.