Dynamic Scoping for People Who Do Not Appreciate Computing History

Posted: January 28th, 2008 | Author: kevin | Filed under: Programming | View Comments

I had a realization helping a co-worker untangle a thorny knot of nested includes in PHP code:

“Nested includes single-handedly recreate what is arguably the worst scoping policy in computing history, dynamic scope.”

The problem we were fighting was that all the variables and state accumulated in the root scope, aka the first script to be executed, was available several scripts away in the leaf scopes, aka the tawdry terminus of the nested includes. Making changes in the root scope, in this case deleting an object creation statement, caused scripts two includes away to fail in a horribly unintuitive manner.

So, when you’re hacking at light speed on the latest gotta-have-it-right-now feature, please take a second and think about your include depth. Be nice to the developers who come after you and don’t nest includes more than two levels deep.


blog comments powered by Disqus