Skip Menu |

This queue is for tickets about the DBM-Deep CPAN distribution.

Report information
The Basics
Id: 29709
Status: rejected
Priority: 0/
Queue: DBM-Deep

People
Owner: Nobody in particular
Requestors: mark.suter [...] dcb.defence.gov.au
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: DBM::Deep should use Carp module [SEC=UNCLASSIFIED]
Date: Tue, 2 Oct 2007 16:32:55 +1000
To: bug-DBM-Deep [...] rt.cpan.org
From: Mark Suter <mark.suter [...] dcb.defence.gov.au>
Folks, The DBM::Deep module is using warn() and die() rather than the much better carp() and croak() from the Carp module. Please add 'use Carp;' to the top module and just search-and-replace warn -> carp and die -> croak. -- Mr Mark Suter, Unix System Administrator, Defence Computing Bureau Contractor to Defence, 02 626 61327 or mark.suter@defence.gov.au Visit ComLaw via http://j6.zwit.org/ for the Section 70 used below. IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the Crimes Act 1914. If you have received this email in error, you are requested to contact the sender and delete the email.
On Tue Oct 02 02:41:42 2007, mark.suter@dcb.defence.gov.au wrote: Show quoted text
> Folks, > > The DBM::Deep module is using warn() and die() rather than the much > better carp() and croak() from the Carp module. > > Please add 'use Carp;' to the top module and just search-and-replace > warn -> carp and die -> croak.
Mark - I understand the process involved to do this change. I would like to hear some justification for the change. What does Carp do for you that the improved die() in 1.0005 does not?Also, would an optional usage of Carp if installed be sufficient? I am loathe to add additional deps if they are not really necessary. I'm not saying "No" - I just want to have some solid rationale. If it ain't broke and all that.
Subject: Re: [rt.cpan.org #29709] DBM::Deep should use Carp module [SEC=UNCLASSIFIED]
Date: Thu, 4 Oct 2007 11:38:15 +1000
To: via RT <bug-DBM-Deep [...] rt.cpan.org>
From: Mark Suter <mark.suter [...] dcb.defence.gov.au>
Rob, Show quoted text
> I would like to hear some justification for the change. What does > Carp do for you that the improved die() in 1.0005 does not?
Using croak() gives an error message from the perspective of caller, that is, gives me the line number in my code and not in your module. Show quoted text
> Also, would an optional usage of Carp if installed be sufficient?
You wouldn't need to make it optional - it's been in the standard Perl distribution since at least 1999 (version 5.0005): http://www.cpan.org/modules/by-module/LWP/GBARR/perl5.005_03.announce Show quoted text
> I am loathe to add additional deps if they are not really > necessary. I'm not saying "No" - I just want to have some solid > rationale. If it ain't broke and all that.
I'm using your module an made the proposed change to the local copy so I could figure out where I was doing the wrong thing. Without croak(), it would have been an uglier patch using caller(). See http://search.cpan.org/perldoc?Carp for more details. Here's the description from that page: The Carp routines are useful in your own modules because they act like die() or warn(), but with a message which is more likely to be useful to a user of your module. In the case of cluck, confess, and longmess that context is a summary of every call in the call-stack. For a shorter message you can use carp, croak or shortmess which report the error as being from where your module was called. There is no guarantee that that is where the error was, but it is a good educated guess. -- Mr Mark Suter, Unix System Administrator, Defence Computing Bureau Contractor to Defence, 02 626 61327 or mark.suter@defence.gov.au Visit ComLaw via http://j6.zwit.org/ for the Section 70 used below. IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the Crimes Act 1914. If you have received this email in error, you are requested to contact the sender and delete the email.
Mark - You haven't addressed my statement that 1.0002 (released 2007-09-20) has an expanded _throw_error() that reports the error at the first non-DBM::Deep line. Does this change address your needs? Or, is there a different reason you wish to have Carp put into DBM::Deep? Basically, you are the first person to ask for Carp to be added and you haven't indicated what the itch you're trying to scratch is. I don't like making changes to code that works unless it's to address something that doesn't work. Particularly if the change is something I don't immediately agree with. I am willing to be convinced, but I need a solid programming reason otherwise I will have to mark this ticket as rejected. I'm not trying to dismiss your report - I'm just not going make a change without a solid reason. Thanks, Rob
Subject: Re: [rt.cpan.org #29709] DBM::Deep should use Carp module [SEC=UNCLASSIFIED]
Date: Fri, 5 Oct 2007 13:52:27 +1000
To: via RT <bug-DBM-Deep [...] rt.cpan.org>
From: Mark Suter <mark.suter [...] dcb.defence.gov.au>
Rob, I appreciate your efforts to seek clarification rather than just mark the ticket as rejected. Thank-you for your patience and thank-you for the module. Show quoted text
> You haven't addressed my statement that 1.0002 (released 2007-09-20) > has an expanded _throw_error() that reports the error at the first > non-DBM::Deep line. Does this change address your needs? Or, is there a > different reason you wish to have Carp put into DBM::Deep?
That only partially address my needs. I have two reasons for asking for DBM::Deep to use Carp: 1) Stylistic: Don't re-invent the wheel - use the standard modules. I appreciate that you don't want to include some esoteric module and complicate dependencies; however, Carp has long been a standard module. 2) Carp has other advanced features, for example, stack back-traces, which are accessible without changing any code, assuming croak() is being used rather than die(). Here's a example showing how to get a back-trace. This is closely based on the example from page 284 of Damian Conway's _Perl Best Practices_. $ perl -x example_script error at example_script line 5 $ perl -MCarp=verbose -x example_script error at example_script line 9 Bar::bar('Bar') called at example_script line 5 Foo::foo('Foo') called at example_script line 2 With this additional data, I have all three points to investigate. This situation is fairly common for me as my scripts often use local modules which in turn use CPAN modules. Here is that "example_script", unindented so -x works: #!/usr/bin/perl # line 1 "example_script" Foo->foo(); package Foo; sub foo { Bar->bar(); } package Bar; use Carp; sub bar { croak "error"; } __END__ -- Mr Mark Suter, Unix System Administrator, Defence Computing Bureau Contractor to Defence, 02 626 61327 or mark.suter@defence.gov.au Visit ComLaw via http://j6.zwit.org/ for the Section 70 used below. IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the Crimes Act 1914. If you have received this email in error, you are requested to contact the sender and delete the email.
I'm not going to be changing to Carp anytime soon.