Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80880 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32339 invoked from network); 20 Jan 2015 15:42:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jan 2015 15:42:57 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.171 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.171 mail-wi0-f171.google.com Received: from [209.85.212.171] ([209.85.212.171:34470] helo=mail-wi0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/00-32230-E777EB45 for ; Tue, 20 Jan 2015 10:42:56 -0500 Received: by mail-wi0-f171.google.com with SMTP id l15so16684252wiw.4 for ; Tue, 20 Jan 2015 07:42:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=VYMDBQ1t2zSgaCoPlgSG/8OHF1qCQXaM5XGoxwrVNps=; b=KHtOvKrSdILg0KdOJJtov1B8LEMu+nUHcg4E1CiTCpry9qGHJuFS/3Yh2acHpPEiL1 qXJ7jLI2FnY88WKZLAk4DONEnOIqdwoeqn9wtecGVbUuL7JFUEwFBjMUsk819BtXzWnz fHeQE09sbBApN2J3VokmYO/dE3MIrHzU3KhHve/JFuzLigum3XO7gtduC0z4DMKaDhuB GWGOxm9fmow8iG9C1L0pNnTOdQyNDNMnhKlqGRvtaP7JFCKRylP10b8ZE6/Iy6YSeoiU uWeKP/aYgr6gPok1hSrm1nt+bVYnHpEDslW/epaZofM6TIIi3LQu/z0R7OKCFMQnE0T4 jODw== X-Received: by 10.194.89.3 with SMTP id bk3mr74393216wjb.92.1421768571398; Tue, 20 Jan 2015 07:42:51 -0800 (PST) Received: from [192.168.0.172] ([62.189.198.114]) by mx.google.com with ESMTPSA id g10sm3505992wic.7.2015.01.20.07.42.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Jan 2015 07:42:50 -0800 (PST) Message-ID: <54BE7749.2010603@gmail.com> Date: Tue, 20 Jan 2015 15:42:01 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] in Operator From: rowan.collins@gmail.com (Rowan Collins) Mike Willbanks wrote on 20/01/2015 03:30: > I am very familiar with the in operator. However, the implementation > would be incomplete without handling loops via the in operator. Many > people when seeing an in operator also think of JavaScript. In that case > the in operator iterates over properties. As such in PHP we should be able > to iterate over associative arrays should the syntax be added. > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in I don't really see how this is related to the in operator, other than that some languages reuse the same keyword for both purposes. My immediate association when I saw this proposal was not "ah, like the loop syntax in JavaScript", but "ah, like the IN() operator in SQL". Given the ability to write foreach ( $foo as $key => $value ), I'm not sure adding a variant syntax of for ( $key in $foo ) has that much value for PHP. Regards, -- Rowan Collins [IMSoP]