Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FW: Attribute::Handlers

0 views
Skip to first unread message

David Feldman

unread,
Oct 25, 2006, 4:34:26 PM10/25/06
to perl5-...@perl.org
At Artur Bergman's suggestion, I am contacting you. Here is my original
message to Artur:

Artur,

I am using your Attribute::Handlers module, but I needed to make
a modification to it to enable better diagnostics. Basically, I have
the [meta-]handler store the filename and line number of the attribute
invocation, and then the handler is passed these as parameters. So, my
handlers now have a call spec of:

sub Args : ATTR(CODE) {
my($package, $symbol, $referent, $attr, $data,
$phase, $filename, $linenum) = @_;
}

That way, if there is an error in attribute processing (for
example, if the 'Args' attribute is applied twice to the same function),
then my error messages can print the filename and line number.

If you'd like, I'll share the code modifications with you. They
are trivial and took about 5 minutes to work into your code.

Sincerely,

David P. Feldman

Rafael Garcia-Suarez

unread,
Oct 26, 2006, 4:39:04 AM10/26/06
to David Feldman, perl5-...@perl.org

I would welcome such a patch, it looks useful.

Rafael Garcia-Suarez

unread,
Oct 27, 2006, 5:22:41 AM10/27/06
to David Feldman, perl5-...@perl.org
On 26/10/06, David Feldman <David....@tudor.com> wrote:
> Rafael,
>
> See the attached output of a context diff against version 0.78.

Thanks.
I had a quick look at your patch, and I have two small remarks :

1. for attributes on scalars (my $foo :Bar), $filename and $linenum
aren't set. Is it possible to handle this case too ? (if not, I'll
apply this patch anyway, only documenting that it works only for
subroutine attributes)

2. You didn't update the docs for the module.

David Feldman

unread,
Oct 27, 2006, 10:02:33 AM10/27/06
to Rafael Garcia-Suarez, perl5-...@perl.org
1. I don't see a reason, looking at the code, that this shouldn't work
universally. The only thing I can think of is that the stack is
different somehow for CODE versus SCALAR handlers invocations, so that
the use of "caller" isn't working for SCALARs. However, I can't
reproduce this problem.

2. No, I didn't update the docs because you might not have been
interested in the patch. Also, since we don't know what's up with #1
above, we should delay on the docs until we're sure my patch actually
works properly.

Maybe you can send me the test program you wrote along with environment
info. like Perl version. We're using Perl 5.6.1 here since it's the
version that's shipping with Solaris 9 and matches our version of
ActiveState on Windows.

=-Dave-F->

Rafael Garcia-Suarez

unread,
Oct 27, 2006, 10:08:48 AM10/27/06
to David Feldman, perl5-...@perl.org
On 27/10/06, David Feldman <David....@tudor.com> wrote:
> Maybe you can send me the test program you wrote along with environment
> info. like Perl version. We're using Perl 5.6.1 here since it's the
> version that's shipping with Solaris 9 and matches our version of
> ActiveState on Windows.

Actually I was testing with 5.9.4 + a bunch of patches, the current
development version of perl. And perl has evolved since then... I'll
have a look anyway.

Rafael Garcia-Suarez

unread,
Nov 9, 2006, 11:03:40 AM11/9/06
to David Feldman, perl5-...@perl.org

Thanks, I've now applied your patch to the development version of
perl, with docs, tests, including two TODO tests for the feature that
doesn't work (yet) : reporting line and filename for scalar
attributes.

0 new messages