Blair Zajac <[EMAIL PROTECTED]> writes:

> I'd like to suggest that HTTP::Status no longer use @EXPORT to export the
> following subroutines:
> 
>       @EXPORT = qw(is_info is_success is_redirect is_error status_message);

I don't think we can do this without breaking too much existing code.

> for the following reason.  I spent several hours tracking this down.

I think your reasons are valid.  I don't use @EXPORT for any new code
I write.  If you can come up with a scheme to fix this for old modules
without breaking code that use them then I would be interested to hear
it.

Regards,
Gisle


> I ran into the following problem demonstrated by the following code:
> 
>       use strict;
>       use HTTP::Response;
> 
>       package A;
> 
>       use HTTP::Status;
>       use vars qw(@ISA);
> 
>       @ISA = qw(HTTP::Response);
> 
>       package main;
> 
>       my $a = HTTP::Response->new(200);
>       my $b = A->new(200);
> 
>       print $a->is_success ? 1 : 0, "\n";
>       print $b->is_success ? 1 : 0, "\n";
> 
> If you comment out or leave the line
> 
>       use HTTP::Status;
>
> then you'll get different output.  If you leave it in, then the result is
> 
>       0
>       1
> 
> and if you take it out, then you get
> 
>       1
>       1
> 
> as you would expect.
> 
> I have a code that subclasses from HTTP::Response and calls
> 
>       $self->is_success
> 
> and if you do as most authors do,
> 
>       use HTTP::Status;
> 
> without thinking, then without knowing it, your package gets is_success
> defined in it.  Then calling
> 
>       $self->is_success
> 
> is really
> 
>       HTTP::Status::is_success($self);
> 
> which not what is expected and won't return true even if $self->code is
> 200.

Reply via email to