[development] module_exists vs. functions_exists?

Earnie Boyd earnie at users.sourceforge.net
Tue Jun 24 19:50:43 UTC 2008

Quoting Michael Prasuhn <mike at mikeyp.net>:

> On Jun 24, 2008, at 10:48 AM, Earnie Boyd wrote:
>> Quoting Frando <frando2 at unbiskant.org>:
>>> In Drupal 7, module_invoke uses module_hook uses  drupal_function_exists. I
>>> don't see why you should not use module_invoke to call API functions.
>> As I have already stated it isn't the defined use of the function.   
>> The defined use of the function is to execute hook implementations.  
>>  If it is used for anything else then confusion will happen and  
>> perhaps cause for a lot of frustration in maintenance.
> I don't buy it. This looks like an excellent use of an existing  
> function that does exactly what is called for. What defines a 'hook'  
> anyway? Is a function not a hook if only one module implements it?  
> Would it be such a stretch to think of every function as a hook to be 
>  invoked in multiple different ways?


Yes it is a bit of a stretch to think of every function as a hook 
because every function isn't supposed to be and doing so causes 
confusion and hardship in maintenance.  The definition of module_invoke 
is to invoke implemented hooks and shouldn't be used as a lazy method 
of calling a function.

Earnie -- http://for-my-kids.com/
-- http://give-me-an-offer.com/

More information about the development mailing list