On Wednesday 28 May 2008 09:11:50 Antony Dovgal wrote:
> On 28.05.2008 10:44, Rasmus Lerdorf wrote:
> > Today's web developer is
> > typically writing half their app in some variety of Ecmascript, either
> > Javascript or Actionscript and this array syntax is second nature to all
> > those folks.
>
> I don't recall any languages to introduce new syntax because it's so handy
> to those who come from PHP and I see no reasons for us to do it either.
> I perfectly understand that we (well, you) did it many times in the
> beginning, but I believe that time is now gone.

That is, maybe, because PHP didn't introduce any "new handy syntax" that could 
be borrowed from other languages.

> The array syntax we have exists for many years and is used in gazillions
> lines of code, it's known to every developer who have ever seen a PHP
> script.

And cursed many times because it's so tedious to write ...

> In the same time, the [] syntax will definitely confuse people (wth? this
> surely looks like invalid syntax!) and will only help to those how don't
> know PHP, but have a certain experience with *script languages, i.e. you're
> going to do a favor for 1% and confuse the remaining 99%.

If you look at the other mails, you'll see that it's not about helping people 
that don't know PHP but other languages, but helping people writing code that 
is more concise and readable ...
[[1,2,3],
 [4,5,6],
 [7,8,9]] is far easier to read than the same thing with array().

> And at last, but not least I don't see anything "more readable and
> maintainable" in using square brackets to initialize arrays when the same
> brackets are used to access them:
>
> $a = [$a[1][2], 3]; /* wth does this mean? */

This "it's unreadable and confusing"-argument is odd. In years of helping 
people in ruby/python*-channels, I have seen many questions, many questions 
that would seem exceedingly dumb, but i can't recall a single time someone 
asking about []-literals for arrays/lists, even [] is the subscript operator 
too for these languages. So you'd imply that seasoned PHP developers are less 
quick to understand than people that are new to other languages ... Btw, do 
you complain because () is used a) to group expressions b) to call functions 
c) for language constructs like for ()? Any "wth"-moments there? Or do you 
wish that strings would be written as string(foo) instead of "foo"?

* Even a language that has the guideline "explicit is better than implicit" 
preferred [] because it's clear and concise ... doesn't that make you wonder?

>
> --
> Wbr,
> Antony Dovgal

Regards,
Stefan

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

Reply via email to