X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2Findirect.pm;h=53dc846c35692076b047854e0aafa6f41e031276;hb=a5339a6ced4d5e3ad1541320476c3d6bf8ff9408;hp=9edc23ef2b7ac0f0d5473cd91b221121196d304d;hpb=7ac06f9de99a3422ab7ea4067d289e6038399970;p=perl%2Fmodules%2Findirect.git diff --git a/lib/indirect.pm b/lib/indirect.pm index 9edc23e..53dc846 100644 --- a/lib/indirect.pm +++ b/lib/indirect.pm @@ -11,13 +11,13 @@ indirect - Lexically warn about using the indirect object syntax. =head1 VERSION -Version 0.13 +Version 0.15 =cut our $VERSION; BEGIN { - $VERSION = '0.13'; + $VERSION = '0.15'; } =head1 SYNOPSIS @@ -29,8 +29,8 @@ BEGIN { use indirect; my $y = new Pear; # ok { - no indirect hook => sub { die "You really wanted $_[0]\->$_[1]" }; - my $z = new Pineapple 'fresh'; # croaks 'You really wanted Pineapple->new' + no indirect hook => sub { die "You really wanted $_[0]\->$_[1] at $_[2]:$_[3]" }; + my $z = new Pineapple 'fresh'; # croaks 'You really wanted Pineapple->new at blurp.pm:13' } } no indirect ':fatal'; @@ -86,10 +86,6 @@ Otherwise, a warning will be emitted for each indirect construct. =cut -my $msg = sub { - "Indirect call of method \"$_[1]\" on object \"$_[0]\" at $_[2] line $_[3].\n" -}; - sub unimport { shift; @@ -99,11 +95,11 @@ sub unimport { if ($arg eq 'hook') { $hook = shift; } elsif ($arg eq ':fatal') { - $hook = sub { die $msg->(@_) }; + $hook = sub { die msg(@_) }; } last if $hook; } - $hook = sub { warn $msg->(@_) } unless defined $hook; + $hook = sub { warn msg(@_) } unless defined $hook; $^H |= 0x00020000; $^H{+(__PACKAGE__)} = _tag($hook); @@ -122,14 +118,28 @@ sub import { (); } +=head1 FUNCTIONS + +=head2 C + +Returns the default error message generated by C when an invalid construct is reported. + +=cut + +sub msg { + "Indirect call of method \"$_[1]\" on object \"$_[0]\" at $_[2] line $_[3].\n" +}; + =head1 CONSTANTS =head2 C -True iff the module could have been built when thread-safety features. +True iff the module could have been built with thread-safety features enabled. =head1 CAVEATS +The implementation was tweaked to work around several limitations of vanilla C pragmas : it's thread safe, and doesn't suffer from a C bug that causes all pragmas to propagate into Cd scopes. + C (no semicolon) at the end of a file won't be seen as an indirect object syntax, although it will as soon as there is another token before the end (as in C or C). With 5.8 perls, the pragma does not propagate into C.