Richard Lynch wrote:
So now we have an invisible operator with a magical symbol '[' which
*sometimes* means create an array, but *sometimes* means to
de-construct an array into individual variables?
The distinction you are making is from an implementation point of view.
From a language users point of view you're just dealing with arrays.
Some people consider the distinction of the two a feature, some consider
it a bug.
That's just disgusting, imho.
To me it makes array usage more orthogonal and hence simpler, but that's
obviously a matter of taste.
What's also beautiful about [] IMHO is the symmetry of the syntax,
list() and array() are asymmetrical which I always found inferior.
- func('foo' => $foo, 'bar' => $bar, ...) equivalent to
func(array('foo' => $foo, 'bar' => $bar, ...), see
http://cschneid.com/php/ for more info
Again, saving 5 characters just to confuse the hell out of idiots like
me does not seem like a "win" for PHP. :-v
It is NOT about saving characters. If is about less clutter. The more
important saving for us is the removal of an additional pair of parens
which look like line-noise when nested. Funnily enough I forgot the
closing parens of array() in my example above :-)
I agree that our function call syntax is somewhat magical as it
automatically starts and stops the array-composition when encountering
key => value pairs so I wasn't really expecting much love for this from
the list. But one can dream :-)
Anyway, back to the main topic: I'm surprised how much hate a syntactic
change like the one proposed by Andi still provokes nowadays when well
established languages like C, C++, Javascript, Python and Ruby seem to
successfully use [] or {} to construct arrays.
My personal summary of this thread is: We won't have syntactic sugar for
common things like arrays, named parameter emulation and the like ever
because it will be killed by the "we already have a way of doing this"
and the "you cannot look it up" argument. Shame, that would be the tiny
language development I'd personally benefit from.
Regards,
- Chris
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php