Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80887 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52581 invoked from network); 20 Jan 2015 19:07:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jan 2015 19:07:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.180 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.214.180 mail-ob0-f180.google.com Received: from [209.85.214.180] ([209.85.214.180:33131] helo=mail-ob0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6B/90-49046-E67AEB45 for ; Tue, 20 Jan 2015 14:07:26 -0500 Received: by mail-ob0-f180.google.com with SMTP id uz6so20387863obc.11 for ; Tue, 20 Jan 2015 11:07:23 -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:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=HyWYn8NaOTV0YusuAr783Bjdxc8Ykctg6omwh9FX97Y=; b=ibmkllF2q80OXXGYG/J0+K+qorbsUe84TOlyyuaqjuwV1AMg4CvpcNtry70a88Y6/4 r7O3GmxY9vHmCsr4kYPUGjdhJfbx8zu3lXz047V9l+bahgAgwltYPfetrmx4uoP1Vjb0 CD+qX1Un+k2YC3I3auYf9SPdkWrubNmECD36SeU1YFgPTkNDP7vECrTq7AVdCQ6s9WfU dcoPmTXqjNB5dEPe6fVh5WybROuPJWv3UwxN4VWPYC01ZdUxxRVT0+fethi6AOG7h2z9 yF2DPza3glsHq6OZTvlZJL9PK8kaTl4rA9leaMpwbUWB55INl+ulH9z5vFXpR3GWcIJA 17rA== X-Received: by 10.202.226.2 with SMTP id z2mr21458970oig.64.1421780843305; Tue, 20 Jan 2015 11:07:23 -0800 (PST) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id u15sm7877297obg.28.2015.01.20.11.07.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Jan 2015 11:07:22 -0800 (PST) Message-ID: <54BEA75D.2080206@gmail.com> Date: Tue, 20 Jan 2015 11:07:09 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: marcio3w@gmail.com, Mike Willbanks CC: Pierre Joye , Andrea Faulds , Niklas Keller , PHP Internals References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] in Operator From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > Agree, but maybe a RFC for "in" operator and a follow up RFC to allow > "in" on "for" context could be a win/win here as long as one feature > doesn't block each other? The problem is "in" is not just "for". The problem is this: when you say "$foo in $bar", is $foo a value or a key? In many languages, $foo would be a value for a list (and a vector) and a key for a map, but in PHP lists, vectors and maps are the same data type, so you can not implement it in the same way as, say, in Python. I.e. in Python: >>> 1 in [1,2,3] True >>> 1 in {1:'a',2:'b',3:'c'} True >>> 1 in {'a':1, 'b':2, 'c':3} False >>> 5 in [5,6,7] True >>> 5 in {0:5,1:6,2:7} False In PHP, even if it'd be possible to implement such semantics (which I'm not sure), it would be very confusing and hard to explain. -- Stas Malyshev smalyshev@gmail.com