Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77398 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70098 invoked from network); 21 Sep 2014 00:22:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Sep 2014 00:22:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.192.181 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.192.181 mail-pd0-f181.google.com Received: from [209.85.192.181] ([209.85.192.181:50686] helo=mail-pd0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3E/72-55126-A2A1E145 for ; Sat, 20 Sep 2014 20:22:02 -0400 Received: by mail-pd0-f181.google.com with SMTP id r10so2182493pdi.40 for ; Sat, 20 Sep 2014 17:21:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=rhaxDOv/9GUdxU/XtaYz1OLHCrzr6EYNfQIYg/V3ALE=; b=l78zOIqcpukDT0ohpGU/VY4F5aOoW6RjhpUKBgbpks24i/Z6bmAGVxGVgbWDzIaiEP ga2NPgHNFi44OX2GLkuvqMq+bS2pr35uZhx8Hf+DFY367uyZDXho2m0YPnAvuUgq8m/m I3ZjYeNXRjPdVpPeK+o5RMJ1QOrhZkP4SeQTCuM0YuKCOEN9j1zm+iuZElQJCSVqRAsB Qm9EalsS2DqAJXAuhQxX74rASKc4kyA38FuuD1bbm8hxhInaiaLe/Y0qNDAAgGmOUJs9 qMum2hGK8HsFuCK2y/747hsaoopS1FU2e5aGcI0Kvwq8cwO3KIoZjzPuXbCgAHgEKoVo e3Sg== X-Gm-Message-State: ALoCoQlfWPaIyCkijS/lVyKgYNDDkqqrPeIHL/7ZkdmhfsBn0jSqusY6ShW72x2KVJGo4ukIrwGj MIME-Version: 1.0 X-Received: by 10.68.143.4 with SMTP id sa4mr12385757pbb.5.1411258918878; Sat, 20 Sep 2014 17:21:58 -0700 (PDT) Sender: php@golemon.com Received: by 10.70.100.67 with HTTP; Sat, 20 Sep 2014 17:21:58 -0700 (PDT) X-Originating-IP: [173.252.71.189] In-Reply-To: References: <1A5B2D07-FEC6-410E-85C9-3FBE2F105104@golemon.com> Date: Sat, 20 Sep 2014 17:21:58 -0700 X-Google-Sender-Auth: b4YgDCSkwCuGeVlEreQe1g2o4NQ Message-ID: To: Leigh , PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Loop... or... From: pollita@php.net (Sara Golemon) On Sat, Sep 20, 2014 at 3:03 PM, Leigh wrote: > On 20 September 2014 20:47, Sara Golemon wrote: >> I like the general idea, but rather than explicitly focusing on the 'or' keyword, how about just giving all loop constructs (do/while/for/foreach) a return value? I'd suggest an integer return value indicating the number of times the loop executed. >> > > mind === blown > > This would open up a huge amount of other functionality I'd never > dreamed of (some of which is quite scary!) > > for($i = for(...) {}; $i < ...) {} > Yikes, I truly hope nobody ever writes that code. Ever. > I'm really not sure I understand the full implication of this though. > This would mean changing loop constructs from statements to > expressions. I wonder how difficult that will actually be, and what > other problems it would cause (I obviously haven't played with this > idea yet). > I admit, I haven't thought it through entirely either. Nor even if it's definitely possible. > It would also mean having to make { default block } into an > expression... with a return value (to be allowed on either side of the > boolean or) > Excellent point, a block only works with T_OR if it has a value. I'm pretty sure that at this point, it doesn't. That does put a monkey wrench into it. Perhaps a lambda could accommodate that? Starts to get ugly though... > Lots to think about here, if it's at all viable this will need it's > own separate RFC, it's a much more invasive change, but definitely a > great idea. > Yeah, I might be trying too hard. Worth exploring a tiny bit though... -Sara