Hacker News new | past | comments | ask | show | jobs | submit login
PHP 5.3.0 Released (php.net)
45 points by danw on June 30, 2009 | hide | past | favorite | 24 comments



Is it just me, or is the namespace syntax HORRIFICALLY ugly?

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_...


I'm not sure I fully get the explanation from your EDIT. If you had a single scope resolution operator ::, classes and namespaces should share the same hash and lookup. A class is, fundamentally, a namespace.

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.


"::" wouldn't work, because it's ambiguous at compile time. Personally I would have preferred ":::", but at some point it turned into a [bike-shed discussion](http://www.bikeshed.com/), and then a few of the core developers made a judgement call. I don't think they realised how controversial a choice they'd made, or perhaps they just didn't think it through, but once the pick was made, there was really no turning back, because of the politics. That's php core for you, and honestly I think it's a major flaw of php.

It's sort of the same way that GOTO entered the language too.


> "::" wouldn't work, because it's ambiguous at compile time.

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.


For some reason the PHP developers think it should be Ok to have a class in your code with the same name as a namespace you're using. I just tested this out with Python and it seems that doing the same thing simply gives you what was last defined, so if you have import lib and then class lib you will just end up with lib as being the class.

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.


mynamespace\function() && call_user_func("mynamespace\\function") FTL. Seriously shows a lack of good judgement by the people implementing new functionality.


The scope resolution operator :: comes directly from C++ world which is standard practice...


The addition of lambda functions and closures is a huge forward step for php.


with late static bindings, hopefully the php-activerecord project will get more attention and users since 5.3 is out of release candidates.

http://github.com/kla/php-activerecord/tree/master


i'm also excited about lsb. i ran into a situation the other day where they would have been extremely helpful


I agree that this release provides some much-needed missing features, but I fear that the culture of php, when presented with these new features, will use them to build even more crufty, difficult-to-read code. As a coder and debugger of much php code, I hope I'm wrong about that.


Oh thank you! Lambda functions! I'm so sick of working with php's silly create_function hack for lambda functions.

This will make working in php so much more convenient!

I'm also glad to see the ternary shortcut (?:) added.


Huge forward step while you are still far far behind = still far behind.


I'm going to upgrade immediately so I can use goto.

Why am I being downmodded? I'm quite serious. I think it'll help clean up some of my previous PHP code.


There are dozens of valid reasons to hate PHP. I don't know why everyone keeps picking on GOTO though.

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.


I'm not hating, I think it'll help clean up my PHP code. Just like you said, there's nothing wrong with GOTOs unless they're abused, just like any other language feature.


How would gotos clean up your code?


They can be extremely useful in error handling. They're also great as a substitute for labeled break statements if your language doesn't support them.


What ever happened to exceptions, which were explicitly invented to handle errors


Yeah. Turns out they're no silver bullet either. These days, my approach is pragmatic: use whatever works and produces the most readable code.


I, and probably a lot of other developers, have an immediate, negative, visceral reaction to "gotos". The reason is simple: If a language provides the appropriate control structures, gotos aren't needed. They will only make your code soupy. In my opinion, if you find yourself using a goto, you should be seriously reconsidering your design.

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


my thoughts exactly


Here is a real question. Why could they not use a simple single : for namespaces? It would be able to parse that just fine. And it would actually look clean/nice.


The ternary operators conflict with that. ?:




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: