Stas Bekman wrote:

Perrin Harkins wrote:

Geoffrey Young wrote:

it's definition is elsewhere, in
Apache::RequestUtil, but Apache::RequestUtil defines
Apache::RequestRec::is_initial_req(). the end result is that you can have
the Perlish $r->is_initial_req() instead of the bulky
Apache::RequestUtil::is_initial_req($r).



I would much prefer the longer one. It's more typing, but it also is much clearer. The current behavior just looks wrong to me.


But Apache::RequestUtil::is_initial_req($r) is wrong. Because it a method and not a function. It makes it impossible to subclass it.

I was just following what Geoff said. The example still works if you make it Apache::RequestUtil->is_initial_req($r) instead.


That's just silly. Most people will need to load: Apache::Request(Rec|IO|Util) and may be Apache::Server(Util)? I see no legitimate reason to make things obscure.

I'm not sure what you mean. Don't you think it's more obscure to require people to load class Foo in order to make a method in class Bar available? If they already have to explicitly load those modules, I can't see why calling methods in those modules would be more confusing.


Alternatively, you could provide arguments to import which would load support modules behind the scenes:

use Apache::RequestRec qw(:io :util);

I'm not crazy about that idea though, since it's a confusing use of import.

Alternatively, you could be sneaky about it and load on demand, hiding this class completely from end users. Here's a simple exampe with no AUTOLOAD evil:

sub is_initial_req {
    my $self = shift;
    require Apache::RequestUtil;
    return Apache::RequestUtil::is_initial_req($self);
}


yuck, that's so inefficient.

It adds a hash lookup and one method call, and it would only exist for people who want to be able to say $r->is_initial_req(). People who are worried about efficiency would call Apache::RequestRecUtil->is_initial_req($r) instead.


- Perrin


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to