Devel::Callsite is a better instance key than join $;,caller()[1,2]

2008-08-07 Thread David Nicol
=head1 NAME

Devel::Callsite - Get current callsite

=head1 SYNOPSIS

  use Devel::Callsite;
  sub $site { return callsite() };
  print $site-(), \n; # prints one number
  print $site-(), \n; # prints a different number

=head1 DESCRIPTION

This function returns the callsite (a number) one level up from where
it was called.  See the tests for an example.  It's useful for
functions that need to uniquely know where they were called, such as
Every::every() (see CPAN for that module).

=head1 HISTORY

Written by Ben Morrow on perl5-porters.  CPAN-ified by Ted Zlatanov.

=head1 AUTHOR

Ben Morrow [EMAIL PROTECTED]
Ted Zlatanov [EMAIL PROTECTED]

=cut

-- 
don't let the perfect become the enemy of the good -- some politician on CNN


Re: Devel::Callsite is a better instance key than join $;,caller()[1,2]

2008-08-07 Thread Ted Zlatanov
I plan to add the interpreter (Perl context, actually) address when I
get a chance, Ben Morrow was kind enough to point out what I was
missing.  Then it will be more correct than the current version.  Does
anyone know if the context address is unique in mod_perl and with
threads?  If not, what can I do?

Ted



Re: Devel::Callsite is a better instance key than join $;,caller()[1,2]

2008-08-07 Thread David Nicol
On Thu, Aug 7, 2008 at 11:01 AM, Ted Zlatanov [EMAIL PROTECTED] wrote:
 I plan to add the interpreter (Perl context, actually) address when I
 get a chance, Ben Morrow was kind enough to point out what I was
 missing.  Then it will be more correct than the current version.  Does
 anyone know if the context address is unique in mod_perl and with
 threads?  If not, what can I do?

 Ted

it seems like if it isn't, extending the instance key using the pid
and tid would be best made the application developers problem.

Suggesting an approach in the Devel::Callsite documentation by
providing example code that produces an instance key that will be
valid in forking and threading environments, would make more sense IMO
than spoiling Devel::Callsite's focus.

-- 
don't let the perfect become the enemy of the good -- some politician on CNN