Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:20109 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56987 invoked by uid 1010); 17 Nov 2005 23:20:01 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 56972 invoked from network); 17 Nov 2005 23:20:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Nov 2005 23:20:01 -0000 X-Host-Fingerprint: 203.194.209.183 webmachine101.com Linux 2.5 (sometimes 2.4) (4) Received: from ([203.194.209.183:38001] helo=webmachine101.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 7F/49-07637-D101D734 for ; Thu, 17 Nov 2005 18:19:59 -0500 Received: (qmail 8863 invoked by uid 512); 17 Nov 2005 23:19:52 -0000 Message-ID: <20051117231951.2586.qmail@webmachine101.com> Reply-To: "=?iso-8859-1?Q?Jevon=20Wright?=" To: "Rasmus Lerdorf" Cc: internals@lists.php.net Date: Thu, 17 Nov 2005 12:19:51 -1100 MIME-Version: 1.0 X-Mailer: WebMail 2.5 X-Originating-IP: 130.123.128.117 X-Originating-Email: jevon@jevon.org Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] dropping curly braces From: jevon@jevon.org ("=?iso-8859-1?Q?Jevon=20Wright?=") Is there anything wrong with having a convention for character access of strings? Most PHP programmers see {} as string access and [] as array access - sure, they might be functionally identical, but its the convention which is important. Jevon > -------Original Message------- > From: Rasmus Lerdorf > Subject: Re: [PHP-DEV] dropping curly braces > Sent: 17 Nov '05 12:11 > > Andreas Korthaus wrote: > >> As far a code readability and obviousness goes, I doubt anybody would > >> guess their way to the $str{5} syntax. > > > > But you know without understanding of any context, that it's the 6th > > character of the string "$str". When you see $var[5], it could be the > > 6th character of a string, or an element of an array... and what about > > the value? You can't be sure that it's a string with length 1, it also > > could be another array, an object, a string with length 4711... > > > > That increases complexity and decreases readability. > > Your argument falls apart there. Try it: > > $a = array("ab","cd","ef"); > echo $a{2}; > > Guess what that prints? {} has nothing to do with strings. They are > 100% equivalent to [] and as such add nothing to clarity. > > -Rasmus > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >