> Unfortunately, something needs to be clarified under the
> previous heading: using array(...) is, in actuality, not
> calling a function.

Neither is include, require, echo, define and other syntax. How would you change those?

> $x[] = "one";
> $x[] = "two";
> $x[] = "three";

> This is clearly quite kludgy, requiring the use of a
> variable to temporarily hold values.

That is opinion. I find this syntax quite clear. There is no reason that $x has to be a temporary variable either. Why not use the variable you want stuff to go into?

> What happens when
> you want to simply give an array of values to a variable
> or even a function?

You use the array() syntax. =) And as many making the PHP4 to PHP5 transition have discovered, passing anything other than true variables (especially arrays) to a function can bite you. Just do a search in the bug system for bogus bugs containing "passed by reference".

> array(
> "one"=>array("happy", "sad", "angry", "jovial"),
> "two"=>array("uno"=>"spiffy", "dos"=>"swell", "tres"=>"neato"),
> "three"=>"juno",
> "four"=>array(array("a happy boy", "a lonely girl"), array("smelly
> feet", "clean socks"), array(...))
> );

I don't really see how that is less clear than:

> ["one"=>["happy", "sad", "angry", "jovial"],
> "two"=>["uno"=>"spiffy", "dos"=>"swell", "tres"=>"neato"],
> "three"=>"juno",
> "four"=>[["a happy boy", "a lonely girl"], ["smelly feet", "clean
> socks"], []]];

Both are a bunch of strings mangled in between either () or []. One has the word array in it which IMO is at least is explanatory.

> Personally, I’ve seen nothing precisely examining why this syntax
> should not be implemented — only reservations to appearing like
> other scripting languages.

The discussion should be about why PHP DOES NEED this. IMO, any new feature request should show strong evidence that PHP is lacking or broken without it. You only present that it would be easier to type and wouldn't look like a function when it is not. Not that I see the difference really to the PHP developer.

As a PHP developer for nearly 9 years now, I don't see why PHP needs this. Why create a new thing that has two syntaxes. PHP has enough legacy stuff like that already.

When PHP started, features were added that did the same things (comments, echo/print, etc.). This likley helped spread the popularity of the language. However, if that trend continued, PHP would not have been useful. Thank goodness the powers that be have stopped the feature bloat.

Now PHP is how people make their living. People rely on it. It can not change on a whim because someone wants to save 5 key strokes when they are creating an array. Use a decent editor and write a macro.

Maybe I am getting old, but if I had my way, the syntax would stop where it is and not add any new bells and whistles. (Actually, I would back it up pre new OO features, but that is a different discussion.) I would rather it be made faster and have the new features (in the way of new extensions) that will be needed as the internet changes.

Brian Moon
dealnews.com
--------------
How to go broke saving money.
http://dealnews.com/

James Crane wrote:
Hi, I've written a short paper on some changes that I'd like to see
made for array literals in PHP. If you could please take a look and
give your thoughts, I'd greatly appreciate it.

http://www.matttoddphoto.com/papers/php_array_literals.html

Thanks,

M.T.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to