Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5258 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55003 invoked by uid 1010); 5 Nov 2003 18:26:39 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 54978 invoked from network); 5 Nov 2003 18:26:39 -0000 Received: from unknown (HELO stella.fastforwardnetwork.com) (209.51.153.50) by pb1.pair.com with SMTP; 5 Nov 2003 18:26:39 -0000 Received: (qmail 351 invoked from network); 5 Nov 2003 19:29:29 -0000 Received: from pd9e615c2.dip.t-dialin.net (HELO hristov.com) (@217.230.21.194) by d.goto.bg with SMTP; 5 Nov 2003 19:29:29 -0000 Message-ID: <3FA93299.5050502@hristov.com> Date: Wed, 05 Nov 2003 19:25:45 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.5) Gecko/20030917 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jaap van Ganswijk CC: internals@lists.php.net References: <5.1.0.14.0.20031105190706.037c5150@localhost> In-Reply-To: <5.1.0.14.0.20031105190706.037c5150@localhost> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Proposal: Array syntax From: php@hristov.com (Andrey Hristov) Jaap van Ganswijk wrote: >At 2003-11-05 09:59 +0100, Michael Walter wrote: > > >>Very cool. >> >>How about supporting .. syntax, btw. as in [1..3] or ["a".."z"]? Might no be the worth, just thinking out loud ;) >> >> > >I'm also in favor of a shorter notation for array() and list(). > >In fact this also helps to ease the problem I have >with 'foreach ($A as $I=>$d)', because it would >then be possible to write: while ([$i,$d]=each($A)). > > Do you know that while(list(..,..) = each($ar)) is kinda "deprecated". You should consider using foreach() which is clearer and the fastest way to traverse an array. while() + each() + list() is the old way (evermore, you have not to forget to reset() your array before the traversal - foreach() does not need this step). Andrey >It's still not as short as I'd like it to be: >'while ($i=>$d in $A)', but it's already a lot >better. > >I'd also like to see ranges supported and propose >to add notations for inclusive and non-inclusive >ranges as: >1..3 inclusive at both ends so equal to 1,2,3 > > >1.<3 non inclusive at the end so equal to 1,2 >1>.3 non inclusive at the beginning so equal to 2,3 >1><3 non inclusive at both ends so equal to 2 > > Use the range() function. PHP is more close to C than to Pascal in my opinion. The language should be simple the standard library should be rich (IMO). Andrey