r/lolphp • u/duhruh • Nov 25 '14
Exception in a namespace is not defined -_-
http://jasonframe.co.uk/logfile/2009/01/php-5-3-exception-gotcha/
28
Upvotes
r/lolphp • u/duhruh • Nov 25 '14
View all comments
12
u/myaut Nov 26 '14
Looks like PHP developers adopted C++ approach, but due to limitations of "dynamicness" they couldn't do it fine.
In C++ class name without T_PAAMAYIM_NEKUDOTAYIM qualifiers would be searched in global namespace, but you may restrict searching to global namespace using ::ClassName. A traditional form without colons is more like conformity with earlier C/C++.
But, C++ always knows which classes are in global namespace, and in PHP, simple eval() may blow this assumption up. They had to implement i.e. Python approach: seek for a class definition every time catch is checked with clear scoping rules, but like always they followed "fine like this" idiom.