Re: using $SIG{__DIE__} correctly (if you must)

2007-02-27 Thread Joshua ben Jore
On 2/27/07, Joshua ben Jore <[EMAIL PROTECTED]> wrote: On 2/27/07, A. Pagaltzis <[EMAIL PROTECTED]> wrote: > Owh goodness aragh *twitch* > > Together with the contortions required to safely examine $@ after > an eval I'm getting tempted to put Unbreak::Eval on the CPAN. Please do. Did Da

Re: using $SIG{__DIE__} correctly (if you must)

2007-02-27 Thread Joshua ben Jore
On 2/27/07, A. Pagaltzis <[EMAIL PROTECTED]> wrote: Owh goodness aragh *twitch* Together with the contortions required to safely examine $@ after an eval I'm getting tempted to put Unbreak::Eval on the CPAN. Please do. Did David Golden ever send his $@ examining snippet to you? It did

Re: using $SIG{__DIE__} correctly (if you must)

2007-02-27 Thread Michael G Schwern
A. Pagaltzis wrote: > * Michael G Schwern <[EMAIL PROTECTED]> [2007-02-27 06:25]: >> $SIG{__DIE__} = sub { >> # We don't want to muck with death in an eval, but $^S isn't >> # totally reliable. 5.005_03 and 5.6.1 both do the wrong thing >> # with it. Instead, we use caller. This also

Re: using $SIG{__DIE__} correctly (if you must)

2007-02-27 Thread A. Pagaltzis
* Michael G Schwern <[EMAIL PROTECTED]> [2007-02-27 06:25]: > $SIG{__DIE__} = sub { > # We don't want to muck with death in an eval, but $^S isn't > # totally reliable. 5.005_03 and 5.6.1 both do the wrong thing > # with it. Instead, we use caller. This also means it runs under >

Re: Why UNIVERSAL::(can|isa) Warn (was Re: using $SIG{__DIE__} correctly (if you must))

2007-02-27 Thread Michael G Schwern
Fergal Daly wrote: > sub isa { > my ($obj, $class) = @_; > # do correct isa stuff > warn "my warning" if (exists $care_about{$class}) or (exists > $care_about{ref $obj}); Consider what if $obj is a subclass of the class you care about? That should probably get checked, too, as it too overrides

Re: Why UNIVERSAL::(can|isa) Warn (was Re: using $SIG{__DIE__} correctly (if you must))

2007-02-27 Thread chromatic
On Tuesday 27 February 2007 14:25, Fergal Daly wrote: > Why not have something like > > --- > package UNIVERSAL::isa; > our %care_about; > > sub import { > my $self = shift; > @[EMAIL PROTECTED] = (); > } > > sub isa { > my ($obj, $class) = @_; > # do correct isa stuff > warn "my warning

Re: Why UNIVERSAL::(can|isa) Warn (was Re: using $SIG{__DIE__} correctly (if you must))

2007-02-27 Thread Fergal Daly
On 27/02/07, chromatic <[EMAIL PROTECTED]> wrote: On Tuesday 27 February 2007 13:58, Michael G Schwern wrote: > What is wrong with the proof-of-concept I proposed? The lines: my $real_isa = \&UNIVERSAL::isa; ... if( ref $obj and eval { $obj->$real_isa("Test::MockObjec

Re: Why UNIVERSAL::(can|isa) Warn (was Re: using $SIG{__DIE__} correctly (if you must))

2007-02-27 Thread chromatic
On Tuesday 27 February 2007 13:58, Michael G Schwern wrote: > What is wrong with the proof-of-concept I proposed? The lines: my $real_isa = \&UNIVERSAL::isa; ... if( ref $obj and eval { $obj->$real_isa("Test::MockObject") } ) { -- c

Re: Object Identification Cold War and the return of autobox.pm (was Re: UNIVERSAL::ref might make ref( $mocked_obj ) sane)

2007-02-27 Thread Michael G Schwern
Rafael Garcia-Suarez wrote: > On 26/02/07, chromatic <[EMAIL PROTECTED]> wrote: >> > Please reconsider autobox. >> >> I second this request. > > autobox in on CPAN and works. Moreover, the intent of the work on > lexical pragmas was to enable people to write their own pragmas and > put them on CPA

Re: Why UNIVERSAL::(can|isa) Warn (was Re: using $SIG{__DIE__} correctly (if you must))

2007-02-27 Thread Michael G Schwern
chromatic wrote: > On Tuesday 27 February 2007 13:42, Michael G Schwern wrote: > >> This handily solves your stated purpose of warning the user about >> MockObjects not being used because of UNIVERSAL::isa mistakes WITHOUT >> warning the user about EVERY mistaken use of UNIVERSAL::isa. > > $ perl

Re: using $SIG{__DIE__} correctly (if you must)

2007-02-27 Thread Michael G Schwern
Eric Wilhelm wrote: > There's nothing vigilante about writing code that assumes other code > will behave properly. If I were going to put something on CPAN that > messed with __DIE__ hooks, it would only be an audit module. Oh good. > I will, however, > refuse to say "local $SIG{__DIE__}" in

Re: Why UNIVERSAL::(can|isa) Warn (was Re: using $SIG{__DIE__} correctly (if you must))

2007-02-27 Thread chromatic
On Tuesday 27 February 2007 13:42, Michael G Schwern wrote: > This handily solves your stated purpose of warning the user about > MockObjects not being used because of UNIVERSAL::isa mistakes WITHOUT > warning the user about EVERY mistaken use of UNIVERSAL::isa. $ perldoc perllexwarn -- c

Re: Why UNIVERSAL::(can|isa) Warn (was Re: using $SIG{__DIE__} correctly (if you must))

2007-02-27 Thread Michael G Schwern
chromatic wrote: > On Tuesday 27 February 2007 00:13, Michael G Schwern wrote: > >> If that were so it would only warn when a MockObject is looked at using >> UNIVERSAL::isa/can() as a function. > > You really ought to read the code, especially the part where Test::MockObject > and UNIVERSAL::i

Re: Object Identification Cold War and the return of autobox.pm (was Re: UNIVERSAL::ref might make ref( $mocked_obj ) sane)

2007-02-27 Thread Rafael Garcia-Suarez
On 26/02/07, chromatic <[EMAIL PROTECTED]> wrote: > Please reconsider autobox. I second this request. autobox in on CPAN and works. Moreover, the intent of the work on lexical pragmas was to enable people to write their own pragmas and put them on CPAN. (*) So just use it. Or, maybe you were

Re: using $SIG{__DIE__} correctly (if you must)

2007-02-27 Thread Eric Wilhelm
# from Michael G Schwern # on Monday 26 February 2007 09:20 pm: >>breaking broken code is easier than >> accounting for ignorance with the unfortunate side-effect that the >> user learns something.  The ignorance goes away and balance is >> restored. > >Again, you're assuming the "user" here to be

Re: Why UNIVERSAL::(can|isa) Warn (was Re: using $SIG{__DIE__} correctly (if you must))

2007-02-27 Thread chromatic
On Tuesday 27 February 2007 00:13, Michael G Schwern wrote: > If that were so it would only warn when a MockObject is looked at using > UNIVERSAL::isa/can() as a function. You really ought to read the code, especially the part where Test::MockObject and UNIVERSAL::isa and UNIVERSAL::can are sep

Re: Why UNIVERSAL::(can|isa) Warn (was Re: using $SIG{__DIE__} correctly (if you must))

2007-02-27 Thread Michael G Schwern
chromatic wrote: > On Monday 26 February 2007 21:20, Michael G Schwern wrote: >> Case in point... my tests started suddenly warning about "UNIVERSAL::isa >> called as a function in Class::DBI". After spending a bunch of time trying >> to figure out what the hell was going on and if Redhat introduc