Re: Syntactic improvement to array
| From: | Richard Lynch | Date: | Mon, 05 Feb 2007 04:21:11 +0000 |
| Subject: | Re: Syntactic improvement to array | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-27781@lists.php.net to get a copy of this message | ||
On Sun, February 4, 2007 1:25 am, Andi Gutmans wrote:
> I thought I may have brought this up a long time ago but couldn't find
> anything in the archives.
> For a long time already I've been thinking about possibly adding a new
> syntax for array(...) which would be shorter. I'd suggest
> [...]. While I am usually not in favor of having more than one way to
> do things, I think it'd look much more elegant especially (but
> not only) for nested arrays.
>
> So what I'm thinking of is:
> array(1, 2, 3) == [1, 2, 3]
> array(1, 2, array("foo", "bar")) == [1, 2, ["foo",
> "bar"]]
> array("key" => 1, "key2" => 2) == ["key" => 1,
> "key2" => 2]
>
> $arr = [1, 2, 3]
> vs.
> $arr = array(1, 2, 3)
>
> Well enough examples given :)
> I think it's not worth doing unless there's overwhelming support as
> it's not desperately needed. But I'd be interested to hear
> people's thoughts. It seems implementation shouldn't be an issue but
> I'd have to dive a bit deeper.
I somewhat prefer seeing 'array' there so I know what the [bleep] is
going on, personally.
-0.3
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?