[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] Eliminate unnecesary warnings about Replacing previous run-mode


On December 15, 2003 04:56 pm, Gabor Szabo wrote:
> On Mon, 15 Dec 2003, Darin McBride wrote:
> > I like it, although I'd rather see that warning gone from the core
> > package.
>
> I also think it should go (or add an option to disable it ?)

I see no advantage to having it at all, personally, so I would not see
any reason to have an option regarding it.

> > Another alternative is to put in your C::A-derived package:
> >
> > sub run {
> >   my $self = shift;
> >   local $SIG{__WARN__} = ...;
> >   $self->SUPER::run(@_);
> > }
> >
> > This allows you to localise as much as possible.  However, given the
> > design of the framework, I don't see there being much advantage to
> > this over your solution.
>
> This is nicer but actually I think mine localises better.

Well, if you were running in mod_perl, yours may affect everyone while
the above will only affect the current run.  However, as I said above,
since it is unlikely that someone will have both their C::A application
running in the same mod_perl interpreter as some other application that
may also want to override $SIG{__WARN__}, my point is mostly academic.

> > For more robustness, you need to check what the current warn is, and,
> > if defined, call it instead of "warn $_[0]".  But that's probably
> > overkill for most of us until perl6 where it becomes easy (I think).
>
> I though I was doing that.
> What do you mean if not what I wrote ?

Something like:

sub run {
  my $self = shift;
  my $oldwarn = $SIG{__WARN__};
  $oldwarn = sub { warn $_[0] } unless ref $oldwarn and ref $oldwarn eq 
'CODE';
  local $SIG{__WARN__} = sub {
    if ($_[0] !~ /Replacing previous run-mode/) {
      &$oldwarn;
    }
  };
  $self->SUPER::run(@_);
}

Again, this is completely overkill.  This is only useful if you think
someone else may have overridden $SIG{__WARN__} somewhere else.  Which,
I think, is unlikely in the C::A world.


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.