On Wed, 28 May 2008, Rasmus Lerdorf wrote: > Mike wrote: > > In my opinion I don't think PHP would be where it is today if it wasn't > > for being so easy to learn and use. > > > > I attribute this directly to the fact that it didn't use a lot of > > "syntax sugar" that is unreadable and can't be "Googled" for. You > > can't Google "[]", and my guess is searching PHP.net for "[]" won't > > return anything useful either. Using Array() is SELF EXPLANATORY! > > Anyone can see that, search Google for "Array" and learn something > > about it. How many man hours are going to be wasted: 1. Searching > > for what the heck [] actually is. > > This "No Magic" mantra is something I have been using since day one to guide > decisions like this in PHP. But I think you guys are misappropriating it. [] > is already our array syntax.
Yes, as an *indexing* mechanism for strings and arrays - that is different from a construct of actually defining it. They are two different things. > $a[1] assumes that the user realize that [] has something to do with > arrays. If they don't, they are out of luck, because as you say, you > can't search for [] and get something useful. But that's already the > case and we are simply building on that existing knowledge. We have > to have a minimum set of operators that we feel reasonable certain > that people understand. ?: is also not easy to search for, yet we > added this ternary shortcut. Likewise, <<< is not easy to look up, but > we added HEREDOC and more recently NOWDOC with this syntax. There is one difference though. The NOWDOC construct allows actually something *new*, whereas [ ] would just be an *alternative* for something can already do. > PHP is about building on the knowledge and experience of the typical > target user. This target user changes slowly as we all get older and > the industry we are in changes and we need to recognize that and adapt > the language appropriately. What is appropriate is of course a really > hard call which is what this is all about. I'd have less issues with adding [] as the array() syntax if it was something that PHP didn't support yet. But we're 12 years down the road now and since arrays were introduced we've always used array(). I realize that there are now other languages that favor this construct, but I don't see why we should then add it as the *exact* same thing as an already existing construct. I'd be greatly disapointed if a construct would make it into PHP. I think it's the wrong way to go by adding cryptic constructs for something that we've already syntax for. Really, adding 5 more chars doesn't make any difference, and using the full "array()" increases readability as it's an explicit statement. Besides the mantra that you mention, there is another one that we shouldn't keep out of the picture either: PHP is suppose to be easy to pick up, and use, and so far we've done that by requiring explicit names for constructs (with the few exceptions of course). This is why we use array(), $ in front of vars, and preg_match over =~. regards, Derick -- Derick Rethans http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php