Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84975 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55933 invoked from network); 16 Mar 2015 03:03:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Mar 2015 03:03:42 -0000 Authentication-Results: pb1.pair.com header.from=hufeng1987@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=hufeng1987@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.45 as permitted sender) X-PHP-List-Original-Sender: hufeng1987@gmail.com X-Host-Fingerprint: 74.125.82.45 mail-wg0-f45.google.com Received: from [74.125.82.45] ([74.125.82.45:36134] helo=mail-wg0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E1/8F-06614-C0846055 for ; Sun, 15 Mar 2015 22:03:41 -0500 Received: by wgra20 with SMTP id a20so29148176wgr.3 for ; Sun, 15 Mar 2015 20:03:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=iGc42JBU4DYZaYNW/N1TlMOMf829kJ/HOUMR+8x51+Q=; b=YWmeGi/TYeZWtRp7QR+CjRpOGmJY/fYtOeG/JI2d2fnHFZuCz2u4j+NpWE6kn9W0Xj 0yzpa8xwC2daIcop5X6SRfVfHHWSGVKPHOEZzc9EsfiVIZT2uRJa/reXQO6TMFKuGe4d C+VI3jIluHwva7YFKiBFRmCoa4QNH6W+JojNxSYY0BuoQXWwFmCjAr08+i56/JKwQ3op HVZJUsUevikAnsaxER+2HqLBsyQYlKW/xUOAZt5uk6PnQZ9zGioo9V7uaId4jg3ThzXP UiLOg+Lbowss5IRv5um4akmsu2iAG5rf9in0lu35oDSdXiwofG4DscREJu3PfnqrDNgS e6Tw== X-Received: by 10.194.174.164 with SMTP id bt4mr83603193wjc.155.1426475017917; Sun, 15 Mar 2015 20:03:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.27.187.198 with HTTP; Sun, 15 Mar 2015 20:03:17 -0700 (PDT) In-Reply-To: <55064508.6050206@eliw.com> References: <5504EF9D.1000707@gmail.com> <55064508.6050206@eliw.com> Date: Mon, 16 Mar 2015 11:03:17 +0800 Message-ID: To: Eli Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC][PRE-VOTE] In Operator From: hufeng1987@gmail.com (Netroby) Does the "in" support this kind of php code ? ```php : > On 3/14/15 10:34 PM, Stanislav Malyshev wrote: > > Hi! > > I'd like to announce that I'll open the vote for the in operator later that > day. > You can find the RFC here: https://wiki.php.net/rfc/in_operator > > I think this operator is unnecessary - we already have perfectly good > function that does the same. > > > Hello Stas ... a quick question for you: I understand why you said you > don't feel it's necessary. (Of course, there are millions of features we > have that aren't necessary, *grin*) > > But I'd like to know from your POV: Does this harm anything? > > Because from my own POV: I see some great benefits of this feature, and my > first thoughts were 'oooh'. The reasons mostly fall around cognitive > dissonance. Two cases in particular: > > 1. > > I feel that this syntax being proposed, much better matches the way that we > think through a problem in the first place. You don't have to take a 'step > back' when coding to refactor your thought process into a function. So if > I'm thinking about a problem I'm thinking (and typing as I go:) > > If we have a zebra in our zoo ... then do X > > I can now with this syntax, write code that directly matches the cognitive > process: > > if ($zebra in $zoo) {} > > Currently, I can speak for myself, I almost always find myself doing a > 'backup' step in coding. Because in this situation my process becomes: > > if ($zebra ... Oh wait, can't do that, need to use in_array > > if (in_array( ... Oh wait, what's the order of parameters again? dang it, > hit php.net or find a recent use. > > if (in_array($zebra,$zoo)) {} ... *shew* > > In the end, yes, you can argue that this is a small thing. But I believe > that the simpler cognitive path that one follows with this new syntax will > bring some great benefit to coders. > > 2. > > Well it's really the same situation. But just that I'm very often dealing > with people 'new or newer to the language'. Professionally training them, > or Unofficial Training, mentoring, helping out ... seeing people at > conferences and talking with them, etc. > > And the newer people to the language often get tripped up on exactly these > kinds of things. Lowering that cognitive barrier to translating one's > thought, to code. I feel is going to be a benefit here. > > ... > > So back to my original question. I respect your opinion, so I'd like to > understand more. Is this just truly a case of "Eh, we have a function > already, this isn't necessary"? Or is there some actual harm you see > caused by it? > > Thanks Stas! > Eli > > -- > | Eli White | http://eliw.com/ | Twitter: EliW |