PHP 5.3.0 Released
php.net
php.net
Couldn't they just overload the "::" syntax or something? Maybe ":::"? Every time I look at an example I feel like something is being escaped.
EDIT: the reasoning as to why "\" is here: http://wiki.php.net/rfc/backslashnamespaces#resolution_of_t_...
It's sort of the same way that GOTO entered the language too.
Why is "::" ambiguous at compile time? It seems to me something is rotten here. C++ using :: for both namespaces and static access of classes. Why didn't PHP go the same way?
I never complain about the choice of operator, I complain about it's need to exist in the first place. :: would have done the job just fine, just as it does in C++, which is where they stole it from in the first place.
Frankly, it's insulting to me that the PHP team doesn't think I have the skills needed to not name my classes after namespace I imported.
namespace foo; function bar(){echo "func\n";}
class foo{ static function bar(){echo "func\n";} }
Should be equivalent as far as invoking them is concerned.
This will make working in php so much more convenient!
I'm also glad to see the ternary shortcut (?:) added.
Why am I being downmodded? I'm quite serious. I think it'll help clean up some of my previous PHP code.
There are situations where it is the clearest and most concise way to express what you want (in modern times we emulate this functionality with continuations, exceptions, etc. because of the stigma attached to to GOTO). See http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pd... for a few examples.
Lots of perfectly respectable languages (Scheme, Lisp, C-Sharp, etc) have GOTOs in some form or another. Yes, you can abuse them, just like you can abuse functions, methods, objects, or anything else.
This article was posted a little while ago, and I thought it gave a very good, non-partisan account of gotos: http://david.tribble.com/text/goto.html