[development] namespaced global variables [WAS: Drupal 6.2 theme system standalone]

Earnie Boyd earnie at users.sourceforge.net
Sat Jun 14 14:41:37 UTC 2008


Quoting Eric-Alexander Schaefer <eric.schaefer at eas-consulting.de>:

> Bob Pepin schrieb:
>> Well, since PHP does have neither namespaces nor modules (okay, you
>> can use classes as some kind of poor man's namespaces if you don't
>> mind writing ClassName::function() all the time), mistake #2 was
>> unavoidable ;)
>
> Every programming language that allows you to name your functions and 
> variables arbitrarily supports namespaces.
>
> $YOUR_NAMESPACE_your_valiable
> YOUR_NAMESPACE_your_function()
> _YOUR_NAMESPACE_your_private_function()
>

Why should Bob do that when Drupal doesn't?  We need to take a stab at 
using a $drupal static array that is controlled by a drupal_register 
function.  If only one argument is passed then drupal_register will 
return the value of the requested variable from the $drupal static 
array.  Else all other arguments are stored as a value of the variable 
and that stored value is then returned.  Note that the first argument 
is always the associative index value for the $drupal array.  If only 
two arguments are passed then the stored value should only be the value 
of the second argument.  If more than two arguments then the argument 
array is stored after the index value is shifted off of the array.  I'm 
working up a patch for this.

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



More information about the development mailing list