Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27740 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29557 invoked by uid 1010); 4 Feb 2007 14:30:17 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 29542 invoked from network); 4 Feb 2007 14:30:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2007 14:30:17 -0000 Authentication-Results: pb1.pair.com header.from=hannes.magnusson@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=hannes.magnusson@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.182.189 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: hannes.magnusson@gmail.com X-Host-Fingerprint: 64.233.182.189 nf-out-0910.google.com Linux 2.4/2.6 Received: from [64.233.182.189] ([64.233.182.189:14084] helo=nf-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FF/94-54400-8FDE5C54 for ; Sun, 04 Feb 2007 09:30:17 -0500 Received: by nf-out-0910.google.com with SMTP id l35so1934003nfa for ; Sun, 04 Feb 2007 06:30:14 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=nr/zRmLAAAAIFXlHlg/2p302j22qFQnTloSQMwJFQOBi1GfJg/VPS7dSceKLNMYM47Red1pIGv8R1qGSuagGuccDPrKe4Kme9gX2AgNt7ogq8iII4tnSXL21/MBZ0Te1+qOzPjqcrf5sYzQmalrJiUgDn3lPAVIVaPI0o43iFy8= Received: by 10.48.254.1 with SMTP id b1mr1017495nfi.1170599414161; Sun, 04 Feb 2007 06:30:14 -0800 (PST) Received: by 10.48.230.3 with HTTP; Sun, 4 Feb 2007 06:30:14 -0800 (PST) Message-ID: <7f3ed2c30702040630v86dc12ckfb5eca200722ecc6@mail.gmail.com> Date: Sun, 4 Feb 2007 15:30:14 +0100 To: "Andi Gutmans" Cc: internals@lists.php.net In-Reply-To: <011701c7482d$a39f6910$6500a8c0@zend.2k> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <011701c7482d$a39f6910$6500a8c0@zend.2k> Subject: Re: [PHP-DEV] Syntactic improvement to array From: hannes.magnusson@gmail.com ("Hannes Magnusson") Hi Andi function typeHinted([] $array = []) { // type hint array, default to empty one if(count($array)) { array_merge($array, ["foo" => []]); // merge $array with array("foo" => array()); return $array; } return []; // empty array } typeHinted([1 => [1 => []]]); // array(1 => array(1 => array())); -1 from me -Hannes On 2/4/07, Andi Gutmans wrote: > Hi, > > 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. > > Andi > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >