develooper Front page | perl.perl5.porters | Postings from December 2006

[PATCH] Fatal v1.03

Thread Next
From:
Jerrad Pierce
Date:
December 10, 2006 11:38
Subject:
[PATCH] Fatal v1.03
Message ID:
200612101938.kBAJcI9D008026@all-night-tool.mit.edu
Below is a patch for the Fatal module, part of the core distribution.
There are two usability problems with the current code, and the patch
fixes one of them.

As it stands the code will only let you Fatal-ize CORE functions or
subroutines in the caller's namespace. It seems perfectly reasonable
to me that a careful author might like to be able to infect another
package with Fatal tersely and explicitly

	package main;
	import Fatal 'Foo::bar';

rather than verbosely and implicitly

	package main;
	{
	  package Foo;
	  import Fatal 'bar';
        }

And secondly, that one might light to Fatal-ize CORE modules globally.
The patch address this second problem, allowing:

	import Fatal 'CORE::GLOBAL::open';

Although it does so with a minimal patch, and another means of doing so
to accept the briefer syntax (GLOBAL_open) used in perlsub might be nice.

=begin
--- /afs/athena.mit.edu/contrib/perl5/arch/share/perl5.8.4/Fatal.pm	Fri Jun  4 02:46:51 2004
+++ /afs/athena.mit.edu/user/b/e/belg4mit/lib/perl5/5.8.0/Fatal.pm	Sun Dec 10 14:11:43 2006
@@ -5,7 +5,7 @@
 use strict;
 our($AUTOLOAD, $Debug, $VERSION);
 
-$VERSION = 1.03;
+$VERSION = 1.04;
 
 $Debug = 0 unless defined $Debug;
 
@@ -99,7 +99,7 @@
 	$sref = \&$sub;
 	$proto = prototype $sref;
 	$call = '&$sref';
-    } elsif ($sub eq $ini) {	# Stray user subroutine
+    } elsif ($sub eq $ini && $sub !~ /^CORE::GLOBAL/ ) {	# Stray user subroutine
 	die "$sub is not a Perl subroutine" 
     } else {			# CORE subroutine
         $proto = eval { prototype "CORE::$name" };
=end

P.S. Author is not susbscribed to p5p
-- 
Free map of local environmental resources: http://CambridgeMA.GreenMap.org
--
MOTD on Prickle-Prickle, the 52nd of The Aftermath, in the YOLD 3172:
Any damn fool can making sweeping generalizations about damn fools.

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