Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5256 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24104 invoked by uid 1010); 5 Nov 2003 18:12:24 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 24080 invoked from network); 5 Nov 2003 18:12:24 -0000 Received: from unknown (HELO molly.0x539.de) (217.28.101.185) by pb1.pair.com with SMTP; 5 Nov 2003 18:12:24 -0000 Received: from pd9e55c28.dip.t-dialin.net ([217.229.92.40] helo=leetspeak.org) by molly.0x539.de with asmtp (Exim 4.14) id 1AHS5d-00060p-LN for internals@lists.php.net; Wed, 05 Nov 2003 19:09:09 +0100 Message-ID: <3FA93D90.6090507@leetspeak.org> Date: Wed, 05 Nov 2003 19:12:32 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20030924 Thunderbird/0.3 X-Accept-Language: en-us, en MIME-Version: 1.0 To: internals@lists.php.net References: <841D90E489448A4F804E1D1B95768BF7D4626D@lis-exchange3.lmu.ac.uk> <3FA930E7.4030405@tabini.ca> In-Reply-To: <3FA930E7.4030405@tabini.ca> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Proposal: Array syntax From: cm@leetspeak.org (Michael Walter) >>> $a = [1,2,$b[11]]; >>> >>> Is that confusing enough for you? ;-) >> >> >> >> What's confusing about it? >> > > The fact that $b[11] references an item of an array, while [1,2,$b[11]] > assigns values to the array $a. The fact that you (and, probably, most > of us) can't tell right off the bat is a clear sign that this is a bad > idea, because it's ambiguous and confusing. > > The same line using the current syntax, btw, would have looked like this: > > $a = array (1,3,$b[11]); Actually, $a = [1,2,$b[11]] would be amazingly clear and expressive in comparison with the rather verbose array() version (same thing with the swap, btw). BTW, remember the alternative range syntax [a..b] I mentioned before? If you consider Markus Boegers (sp?) iterators extension, wouldn't it be top cool to have [a..] syntax, too (yielding an iterator)? And have versions of map/filter/reduce support iterators, too? :) Well, just thinking out loud, you remember ;) > As you can see the ambiguity is gone--square brackets are used for one > purpose and nothing else. Actually, do you realize that you use () both for "grouping" and for application? I can't see anything wrong with using square brackets for array element access and array creation, to be honest. Cheers, Michael