Perrin Harkins wrote:
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.

it's not the same. this call is:


Apache::RequestUtil::is_initial_req('Apache::RequestUtil', $r)

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.

Heh, I guess we have lost the track of who wants what. I started this thread exactly suggesting to eliminate this obscurity and not advocating for it.


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.

that's what I've just suggested (Josh's idea). Though it's better be some other common name which will handle any groups and not Apache::RequestRec, because you don't necessarily need Apache::RequestRec at all.


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.

to be efficient it needs to do: goto &$AUTOLOAD; after loading Apache::RequestUtil, so it'll happen only once.


What if you don't load 'Apache::RequestRec'? Who is going to load that wrapper?

What if people do load Apache::RequestUtil:

$r->is_initial_req($self)

now you've sub redefined in either of the two modules.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


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



Reply via email to