You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2004/09/10 00:34:02 UTC

better name to ModPerl::Util::unload_module?

After looking at the doc again, I think it's misleading to call this 
function unload_module. Since it's doesn't undo what the module has 
loaded. It unloads a specific stash (package name) no more and no less. A 
module could have inserted things into other packages, and other modules 
may have added other things into the current package, and unload_module 
won't undo those and will overundo the others. So may be it's better to 
call it unload_stash? It's good that the name is not end user friendly 
(i.e. requires the knowledge of perl internals), since people shouldn't be 
using it, unless they know what they are doing.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: better name to ModPerl::Util::unload_module?

Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.

Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> 
>>
>>Stas Bekman wrote:
>>
>>
>>>Philippe M. Chiasson wrote:
>>>
>>>
>>>>Stas Bekman wrote:
>>>>
>>>>
>>>>
>>>>>After looking at the doc again, I think it's misleading to call this 
>>>>>function unload_module. Since it's doesn't undo what the module has 
>>>>>loaded. It unloads a specific stash (package name) no more and no less.
>>>>
>>>>
>>>>
>>>>It's not quite that simple, it gets rids of a module in preparation for
>>>>reloading it (eval "use $module").
>>>>
>>>>It clears the module's stash
>>>>It removes the module from %INC
>>>
>>>
>>>
>>>oh i've missed that one. in fact remember that a module could be 
>>>autovivified from anywhere. So make sure that it handles the case when 
>>>you don't have a real module Foo/Bar.pm but you do have sub 
>>>Foo::Bar::test inserted from another place.
>>
>>
>>Well, if you call unload_module("Foo::Bar") it will wipe out sub 
>>Foo::Bar::test {}
>>and fail to find Foo/Bar.pm in %INC and leave it alone.
> 
> 
> perfect.
> 
> 
>>>and please add that to the doc too.
>>
>>
>>Not sure what you want to see in there ?
> 
> 
> That it attempts to remove Foo/Bar.pm from %INC when 
> unload_module("Foo::Bar") is called. This is not obvious and better be 
> documented.
> 
> 
>>>Right, so not _stash, but neither _module. even Symbol calls it 
>>>delete_package which is probably much closer, but still doesn't cover.
>>>
>>>clean_namespace()
>>>clear_namespace()
>>>clean_package()
>>>clear_package()
>>
>>
>>I like clear_package(), clear_module() maybe ?
> 
> 
> I'd go with the package, module may contain more than one package and 
> therefore misleading. unload_package or clear_package sounds good. I think 
> unload_package is a good choice.

Yeah, and the funny thing is that unload_package() is what the function
is called currently. I just mistyped it when I documented it. So this thread
can be safely forgotten now that I updated the documentation.

-- 
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Re: better name to ModPerl::Util::unload_module?

Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
> 
> 
> Stas Bekman wrote:
> 
>> Philippe M. Chiasson wrote:
>>
>>>
>>> Stas Bekman wrote:
>>>
>>>
>>>> After looking at the doc again, I think it's misleading to call this 
>>>> function unload_module. Since it's doesn't undo what the module has 
>>>> loaded. It unloads a specific stash (package name) no more and no less.
>>>
>>>
>>>
>>> It's not quite that simple, it gets rids of a module in preparation for
>>> reloading it (eval "use $module").
>>>
>>> It clears the module's stash
>>> It removes the module from %INC
>>
>>
>>
>> oh i've missed that one. in fact remember that a module could be 
>> autovivified from anywhere. So make sure that it handles the case when 
>> you don't have a real module Foo/Bar.pm but you do have sub 
>> Foo::Bar::test inserted from another place.
> 
> 
> Well, if you call unload_module("Foo::Bar") it will wipe out sub 
> Foo::Bar::test {}
> and fail to find Foo/Bar.pm in %INC and leave it alone.

perfect.

>> and please add that to the doc too.
> 
> 
> Not sure what you want to see in there ?

That it attempts to remove Foo/Bar.pm from %INC when 
unload_module("Foo::Bar") is called. This is not obvious and better be 
documented.

>> Right, so not _stash, but neither _module. even Symbol calls it 
>> delete_package which is probably much closer, but still doesn't cover.
>>
>> clean_namespace()
>> clear_namespace()
>> clean_package()
>> clear_package()
> 
> 
> I like clear_package(), clear_module() maybe ?

I'd go with the package, module may contain more than one package and 
therefore misleading. unload_package or clear_package sounds good. I think 
unload_package is a good choice.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: better name to ModPerl::Util::unload_module?

Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.

Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> 
>>
>>Stas Bekman wrote:
>>
>>
>>>After looking at the doc again, I think it's misleading to call this 
>>>function unload_module. Since it's doesn't undo what the module has 
>>>loaded. It unloads a specific stash (package name) no more and no less.
>>
>>
>>It's not quite that simple, it gets rids of a module in preparation for
>>reloading it (eval "use $module").
>>
>>It clears the module's stash
>>It removes the module from %INC
> 
> 
> oh i've missed that one. in fact remember that a module could be 
> autovivified from anywhere. So make sure that it handles the case when you 
> don't have a real module Foo/Bar.pm but you do have sub Foo::Bar::test 
> inserted from another place.

Well, if you call unload_module("Foo::Bar") it will wipe out sub Foo::Bar::test {}
and fail to find Foo/Bar.pm in %INC and leave it alone.

> and please add that to the doc too.

Not sure what you want to see in there ?

> 
>>It dl_closes the associated .so file if the module was DynaLoaded.
>>
>>
>>>A module could have inserted things into other packages, and other 
>>>modules may have added other things into the current package, and 
>>>unload_module won't undo those and will overundo the others. So may be 
>>>it's better to call it unload_stash?
>>
>>
>>Isn't that an understatement of what the function does ?
>>
>>
>>>It's good that the name is not end user friendly (i.e. requires the 
>>>knowledge of perl internals), since people shouldn't be using it, 
>>>unless they know what they are doing.
>>
>>
>>Definetely. There are very few reasons why one would want to use something
>>like that. And we still know that as much as I might want to, _unloading_ a
>>Perl module isn't 100% feasible, really ;-(
> 
> 
> Right, so not _stash, but neither _module. even Symbol calls it 
> delete_package which is probably much closer, but still doesn't cover.
> 
> clean_namespace()
> clear_namespace()
> clean_package()
> clear_package()

I like clear_package(), clear_module() maybe ?

> reset_namespace()
> ...
> 

-- 
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Re: better name to ModPerl::Util::unload_module?

Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
> 
> 
> Stas Bekman wrote:
> 
>> After looking at the doc again, I think it's misleading to call this 
>> function unload_module. Since it's doesn't undo what the module has 
>> loaded. It unloads a specific stash (package name) no more and no less.
> 
> 
> It's not quite that simple, it gets rids of a module in preparation for
> reloading it (eval "use $module").
> 
> It clears the module's stash
> It removes the module from %INC

oh i've missed that one. in fact remember that a module could be 
autovivified from anywhere. So make sure that it handles the case when you 
don't have a real module Foo/Bar.pm but you do have sub Foo::Bar::test 
inserted from another place.

and please add that to the doc too.

> It dl_closes the associated .so file if the module was DynaLoaded.
> 
>> A module could have inserted things into other packages, and other 
>> modules may have added other things into the current package, and 
>> unload_module won't undo those and will overundo the others. So may be 
>> it's better to call it unload_stash?
> 
> 
> Isn't that an understatement of what the function does ?
> 
>> It's good that the name is not end user friendly (i.e. requires the 
>> knowledge of perl internals), since people shouldn't be using it, 
>> unless they know what they are doing.
> 
> 
> Definetely. There are very few reasons why one would want to use something
> like that. And we still know that as much as I might want to, _unloading_ a
> Perl module isn't 100% feasible, really ;-(

Right, so not _stash, but neither _module. even Symbol calls it 
delete_package which is probably much closer, but still doesn't cover.

clean_namespace()
clear_namespace()
clean_package()
clear_package()
reset_namespace()
...

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: better name to ModPerl::Util::unload_module?

Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.

Stas Bekman wrote:
> After looking at the doc again, I think it's misleading to call this 
> function unload_module. Since it's doesn't undo what the module has 
> loaded. It unloads a specific stash (package name) no more and no less.

It's not quite that simple, it gets rids of a module in preparation for
reloading it (eval "use $module").

It clears the module's stash
It removes the module from %INC
It dl_closes the associated .so file if the module was DynaLoaded.

> A module could have inserted things into other packages, and other modules 
> may have added other things into the current package, and unload_module 
> won't undo those and will overundo the others. So may be it's better to 
> call it unload_stash?

Isn't that an understatement of what the function does ?

> It's good that the name is not end user friendly 
> (i.e. requires the knowledge of perl internals), since people shouldn't be 
> using it, unless they know what they are doing.

Definetely. There are very few reasons why one would want to use something
like that. And we still know that as much as I might want to, _unloading_ a
Perl module isn't 100% feasible, really ;-(

-- 
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Re: better name to ModPerl::Util::unload_module?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Stas Bekman wrote:
> After looking at the doc again, I think it's misleading to call this
> function unload_module. Since it's doesn't undo what the module has
> loaded. It unloads a specific stash (package name) no more and no less.
> A module could have inserted things into other packages, and other
> modules may have added other things into the current package, and
> unload_module won't undo those and will overundo the others. So may be
> it's better to call it unload_stash? It's good that the name is not end
> user friendly (i.e. requires the knowledge of perl internals), since
> people shouldn't be using it, unless they know what they are doing.
>

others that come to mind are clear_stash and clear_namespace, but any is
fine with me.

--Geoff

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org