[development] Drupal 6.2 theme system standalone

Bob Pepin bob.pepin at gmail.com
Sat Jun 14 13:42:51 UTC 2008


Well, since the original reason for using the variable here was being
able to shorten down DrupalThemeStandalone::init() to $theme->init()
in a 10-line test script, making that
$DrupalThemeStandalone_TestScript_theme->init() would kind of defeat
the purpose.

But you are right of course that global variables used in libraries
should always have some sort of LIBRARY_NAME prefix.

But then again I could also have avoided the problem by simply putting
all of my code inside a main() function, instead of naively expecting
an innocent looking 5-letter variable name like $theme not to be used
already by some functions somewhere as a global variable to keep their
state.

On Sat, Jun 14, 2008 at 15:07, Victor Kane <victorkane at gmail.com> wrote:
> That's not strictly 100% accurate, since with real namespaces, the scope
> would be restricted; although for the purposes here, your suggestion would
> be practical.
>
> Victor Kane
> http://awebfactory.com.ar
>
> On Sat, Jun 14, 2008 at 9:56 AM, Eric-Alexander Schaefer
> <eric.schaefer at eas-consulting.de> wrote:
>>
>> 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()
>>
>> HTH,
>> Eric
>
>


More information about the development mailing list