Brothers and sisters, every time I touch php I want to say 'yak'! This time php dev-team announced new php features. As I understood php.v6 features. What will we have?
-
GOTO operator. Yes, I didn't misspell: GOTO. All language paradigms, all algorithms architects try to avoid goto except php developers =/.
Here how you can use it:
for ($i = 0; $i < 9; $i++) { if (true) { break blah; } echo "not shown"; blah: echo "iteration $i\n"; }
They even named it as 'break'. They probably think that 'break' is not 'goto' =). But yes, they BREAK the common sane ;). Developers say: Goto is currently missing in PHP, and although there is a limited use for this construct in some cases it can reduce the amount of code a lot. I should say: It doesn't matter how many code you have. But it does matter how easy you can read and understand it. -
ifsetor function(?operator?). It shall replace "'condition'?'yes':'now';" construction.
Here how you can use it:
$foo = ifsetor($_GET['foo'], 42);
As for me that's nonsense. This doesn't make things easier but complicates the language. In python persists such construction for dict: dictobject.get('key', 'defvalue'). This will return 'defvalue' if no value in dict with given 'key' is associated. Besides, this is not a global function or operator. This is a method of the object and, yes, it simplifies the construction "dictobject.has_key('key') and dictobject['key'] or 'defvalue'" - php will be unicode. At last.
- Some functionality will be cleaned up. This is not bad, but how about old-code support? They should think first before implementation of 'new functionality' that will be cleaned up eventually.
- No more 'safe_mode'. I wonder why php should had been unsafe in some circumstances ;).
- We remove support for dynamic break levels. That's one of the useful php features. Every time I had to write code in other languages that should break more than one loop I think that php's break feature will be good here. I even implemented it in my 'libdodo' project. The reason of remove: "break $var" doesn't really work. I think they should fix this behavior rather then remove this break behavior.
- Named function parameters. That's good =). But I don't like the implementation:
function foo ($a = 42, $b = 43, $c = 44, $d = 45) { echo "$a $b $c $d\n"; } foo(c => 54, b => 53);
I think there should be "foo($c = 54, $b = 53)" to keep the coding style. - Interfaces may specify the __construct() signature.We didn't see a reason why this shouldn't be allowed, but Andi seems to have a reason for it.Genius!
- name spaces. Good thing. But I wonder why they are named as 'modules'.
No comments:
Post a Comment