Re: Please review new Perl 5 Module List

Martijn Koster (m.koster@nexor.co.uk)
Tue, 28 Feb 1995 11:19:06 +0000


m.koster@nexor.co.uk writes:
> > And all of a sudden things move fast :-)
>
> We'll see :-(

Well, I hope to get a little bit more time to work on this soon.  How
up-to-date is your tar file? Can I send diffs? I'll try and put in the
URL mehods and the callback/file handling tonight (if you haven't done
it yet :).

> > > > I do miss some of the higher level error management functions I have,
> > > > for example to translate codes to mnemonics (and error messages).
> > > 
> > > Do you mean callbacks or some functions to do:
> > > 
> > >   $WWW::RespMessage{WWW::RC_SOMETHING}
> > > 
> > > stuff.
> > 
> > I need to lookup rc_code->mnemonic. Say I do a get, and receive 600,
> > then I need to be able to translate that to RC_WHATEVER, if these
> > mnemonics are used as indices into hashes. This might be another
> > argument not to use subs to define the constants.

I may have been to hasty there; The RC_WHATEVER actually resolve to
the numbers, so the numbers are used as indices right? In that case
ignore the sentence above...


> > I also want to be able to do WWW::isRedirect(600) etc to group
> > errors without having to check for all possible values.
> 
> The alternatives for return value from WWW::request are (as I see it):
> 
>    1) an integer value and provide some package functions:
>         WWW::mnemonic($rc)
>         WWW::isRedirect($rc)
> 
>    2) a ref to some object with methods like
>         $rc->code
>         $rc->mnemonic
>         $rc->isRedirect
> 
> If we return an object, then we might stuff more into it, like the
> returned headers and the content.  I think I like option 2.

Yes... That would also allow failed_request to return the description
of the failure in normal text as well as HTML, allowing personalised
error reporting. 


> > Not really:
> > 
> > sub scheme {
> >    my($this, $scheme) = @_;
> >    my($oldscheme) = $this->{'scheme'};
> >    $this->{'scheme'} = $scheme if (defined $scheme);
> >    return($oldscheme);
> > }
> 
> Yes, I though of this just after I sent the reply, but you should be
> able to set the attribute to 'undef', ie:
> 
>    $url->scheme(undef)
>    $a = url->scheme;

In the current scheme it doesn't look like you need to be able to set
it to undef: the rest of the module tests only with !, not with
defined. Don't know off-hand is this is a deficiency in the current
setup, I don't think any cases are missed unless 'http://web/hi#' (ie
with an empty FRAG) is different from 'http://web/hi' (with an undef
FRAG). Hmm, where's the draft...

> This might do the job:
> 
>  sub scheme {
>     my $this = shift;
>     my($oldscheme) = $this->{'scheme'};
>     $this->{'scheme'} = shift if (@_);
>     return($oldscheme);
>  }

Even neater.

Any thoughts on the desirability/hassle of splitting "sub request"
into "request_response" and "request_data"?

-- Martijn
__________
Internet: m.koster@nexor.co.uk
X-400: C=GB; A= ; P=Nexor; O=Nexor; S=koster; I=M
X-500: c=GB@o=NEXOR Ltd@cn=Martijn Koster
WWW: http://web.nexor.co.uk/mak/mak.html