On Tue Jun 07 21:41:45 2011, dmcbride wrote: > > This is a bug report for perl from dmcbride@naboo.to.org, > generated with the help of perlbug 1.39 running under perl 5.12.3. > > > ----------------------------------------------------------------- > [Please describe your issue here] > > This is pretty much the reverse of 7589 and is largely summed up > by Nick Ing-Simmons in > http://rt.perl.org/rt3/Ticket/Display.html?id=7589#txn-18370 > > Because the backtrace does not show anything about the object, it > is of limited use. Some feature addition that allowed the user > and/or object to detail how to describe references in a backtrace > would make debugging with Carp far easier. For example, allowing > objects to have a CARP_TRACE method which would do the "obvious" > thing that stringify would do, but is not permitted to recurse back > into Carp. Or even having Carp detect this recursion with a localised > global variable, and only resorting to overload::StrVal if the > recursion > is attempted/detected. > > Similarly, from the user perspective, especially for non-object > references, a way to override the stringification of HASHes, ARRAYs, > and SCALARs (and maybe objects as well). By inserting some function > somewhere, I could dump the hash in question via JSON::XS, and see > the entire hash in the output. Given the PBP suggestion to pass in > parameters via a hash reference, this would allow developers to use > the PBP suggestion and still gain value from Carp::cluck and > Carp::confess. > > e.g.: > > package Foo; > > use overload > q[""] => 'as_string'; > > sub new { > shift; > return bless {@_} > } > > sub as_string > { > my $self = shift; > join '=', ref $self, $self->{key} || "<no key>"; > } > > package main; > > use Carp; > > my $f = Foo->new(key => 'Baz'); > print "overload: $f\n"; > with_longmess($f, {bar=>'buzz'}); > > sub with_longmess > { > my $g = shift; > Carp::cluck "longmess:"; > } > > Output: > > overload: Foo=Baz > longmess: at longmess.pl line 28 > main::with_longmess('Foo=HASH(0xacad48)', 'HASH(0xb1cc90)') > called at longmess.pl line 23 > > Unfortunately, this tells me very little about what the parameters > were. > Reproduced with Perl 5.16.0, Carp version 1.26. --- via perlbug: queue: perl5 status: new https://rt.perl.org:443/rt3/Ticket/Display.html?id=92446Thread Previous | Thread Next