[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: A common base exception object for Perl - RFC



Martyn Pearce wrote:

> As we're on naming, to_string would be more consistent with other perl
> modules.

Bah. I /like/ mixed case names like C<toString> :)

Point taken, though...

> > PROPOSED INTERFACE
> >
> >       use Exception qw(-stacktrace);
> >
> >       my $e=new Exception 'text';
> >
> >       my $f=new Exception -text=>'foo', -class=>'Error',
> >                       -name=>'bar', -errcode=>$!, -exitcode=>23;
> >
> 
> the use of -foo for configuration items seems to me to be something
> picked up from Tk and/or analogy with command-line calls.  I'm not
> convinced that they help here; and I don't see them used commonly
> through the non-Tk modules.

There's no implicit connection between this call interface and the
internal implementation. My sole reason for this is to allow named
parameters without having to suffer the overhead of generating a hashref
for the call; the leading '-'s are just there to make it easy to
identify key names. Remember from my original message that I'm allowing
calls like:

	my $e=new Exception 'arbitrary error text' -exitcode=>5;

Of course, if this interface gets shot down in flames, anything goes...

> Part of the very purpose of OO implementations is to encapsulate
> data-structure --- the client certainly should not be utilizing the
> HASHness of a particular impl.; everything should be called via methods.

Total agreement!

Pete
-- 
use Disclaimer::Standard;	# Motorola GSM Software Factory
my $phone='+44 1793 564450';	# "'Not twisted,' Salzy once said of
my $fax='+44 1793 566918';	#  her own passion, 'it is helical.
my $mobile='+44 7973 725120';	#  That sounds better.'"


Follow-Ups from:
Larry Wall <larry@wall.org>
References to:
"Redford, John" <John.Redford@fmr.com>
Martyn Pearce <m.pearce@inpharmatica.co.uk>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]