Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38421 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40859 invoked from network); 19 Jun 2008 17:57:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jun 2008 17:57:45 -0000 Authentication-Results: pb1.pair.com header.from=andrei@gravitonic.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=andrei@gravitonic.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain gravitonic.com from 74.125.44.29 cause and error) X-PHP-List-Original-Sender: andrei@gravitonic.com X-Host-Fingerprint: 74.125.44.29 yx-out-2324.google.com Received: from [74.125.44.29] ([74.125.44.29:32889] helo=yx-out-2324.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 52/20-63224-81E9A584 for ; Thu, 19 Jun 2008 13:57:45 -0400 Received: by yx-out-2324.google.com with SMTP id 3so157047yxj.83 for ; Thu, 19 Jun 2008 10:57:42 -0700 (PDT) Received: by 10.115.77.1 with SMTP id e1mr3048567wal.58.1213898261192; Thu, 19 Jun 2008 10:57:41 -0700 (PDT) Received: from ws-050.prv.corp.outspark.com ( [12.51.40.234]) by mx.google.com with ESMTPS id m26sm1210436pof.1.2008.06.19.10.57.38 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 19 Jun 2008 10:57:39 -0700 (PDT) Message-ID: <485A9E11.2080403@gravitonic.com> Date: Thu, 19 Jun 2008 10:57:37 -0700 User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070807) MIME-Version: 1.0 To: Stefan Walk CC: internals@lists.php.net, Arvids Godjuks , "Edward Z. Yang" References: <77972256-ED0C-4FCE-8DEF-8283FE1BBFC5@roshambo.org> <28.6B.06776.09A76584@pb1.pair.com> <9b3df6a50806162327r52ae3ad9g65d56c0916571185@mail.gmail.com> <200806171121.03786.et@php.net> In-Reply-To: <200806171121.03786.et@php.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] deprecation status of $str{42} versus $str[42] From: andrei@gravitonic.com (Andrei Zmievski) That's why there is TextIterator. And it's also much faster (in PHP 6) than iterating through string using indexes. -Andrei Stefan Walk wrote: > On Tuesday 17 June 2008 08:27:37 Arvids Godjuks wrote: >> 2008/6/16 Edward Z. Yang : >>> PHP userland code may not treat strings as first class arrays, but >>> that's certainly how they are represented internally. >>> >>> Anyway, it would be neat if we could get that foreach syntax to work. I >>> get sick of for($i = 0, $c = strlen($str); $i < $c; $i++) very quickly. >> Totaly agree, the best example from the whole thread > > > You're not learning from the mistakes of other languages (ruby in this case, > which removed Enumerable from String in 1.9) ... "foreach" makes no sense for > strings, because it's unclear what you want (with unicode terminology here, > as this is for php6): > "for each byte" "for each codeunit" "for each codepoint", or "for each line", > or ... if you want to use foreach in your example, just do > foreach (str_split($str) as $value) { ... > > Regards, > Stefan >