Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69205 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17919 invoked from network); 18 Sep 2013 17:50:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Sep 2013 17:50:48 -0000 Authentication-Results: pb1.pair.com header.from=bobwei9@hotmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=bobwei9@hotmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain hotmail.com designates 65.55.111.87 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.87 blu0-omc2-s12.blu0.hotmail.com Windows 2000 SP4, XP SP1 Received: from [65.55.111.87] ([65.55.111.87:59500] helo=blu0-omc2-s12.blu0.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/13-01324-4F7E9325 for ; Wed, 18 Sep 2013 13:50:45 -0400 Received: from BLU0-SMTP465 ([65.55.111.72]) by blu0-omc2-s12.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 18 Sep 2013 10:50:41 -0700 X-TMN: [ICcim4/Lj0vzn8HZnv9PciW0Pz3R3J5h] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Received: from [192.168.178.42] ([188.115.28.77]) by BLU0-SMTP465.phx.gbl over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Wed, 18 Sep 2013 10:50:38 -0700 Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) In-Reply-To: Date: Wed, 18 Sep 2013 19:50:36 +0200 CC: Developers List PHP Mailing Content-Transfer-Encoding: quoted-printable References: <49D57F66323040FC9AE48244DAAF3771@gmail.com> <012B9378-3C3A-4169-96D3-3B57D6C7A82C@seancoates.com> To: Leigh X-Mailer: Apple Mail (2.1508) X-OriginalArrivalTime: 18 Sep 2013 17:50:38.0709 (UTC) FILETIME=[95D41A50:01CEB497] Subject: Re: [PHP-DEV] Re: Allowing is_* functions to accept multiple parameters From: bobwei9@hotmail.com (Bob Weinand) Am 18.9.2013 um 18:09 schrieb Leigh : > On 18 September 2013 14:50, Sean Coates wrote: >> i.e. is_null($a, $b, $c) would be the same as is_null($a) && = is_null($b) >> && is_null($c) >>=20 >> Note that this would not be semantically equivalent in this form, = even if >> `is_null()` did accept multiple parameters, because of the = short-circuiting >> with `&&`: >=20 > See below. >=20 > On 18 September 2013 15:53, Patrick ALLAERT = wrote: >> 2013/9/18 Chris London : >>> I like the naming convention of are_*. For me personally it isn't = directly >>> intuitive that the multiple parameters of is_* would be compared = with an && >>> and not an ||. >>=20 >> isset() already operates that way, keeping "is_" and implementing it >> as originally proposed by Leigh would, at least, be consistent. >=20 > Indeed, my proposal was to mimic short circuiting as isset() does it, > evaluating LTR and returning false at the earliest opportunity. At least, from a technical point, evaluating LTR would require to change = the engine (would be some more complex change as it would require to switch between = contexts and being able to execute the ZEND_SEND_VAL opcodes one by one (evaluate first argument and execute until next ZEND_SEND_VAL, and if one doesn't = match the conditions, jump to the end of the sending args) etc.) Just have a look = at the complicated opcodes, just for isset: http://3v4l.org/l3Z4l/vld And now do something = like this for real functions (e.g. not a language construct) at run-time, because we'd have = to do the function lookup at run-time (just because the name of the function might = be unknown at compile time thanks to $var =3D "func"; $var();) The other alternative here is (like isset), just changing it into a = language construct. (which I consider also suboptimal, as it disallows still things like $var =3D "is_*"; $var($arg1, $arg2, $arg3);). So, I am basically -1 on this, as this a) requires some deep engine = change in the opcodes' handling flow or needs a change of language parser (well, if = someone could provide a nice patch which implements this in a nice way, I'm in favor = of this) and b) without LTR it effectively needs to evaluate everything, what would = be a performance drop as opposed to the current (encouraged) method of just = and'ing all the is_* calls. Then you also just could do in userspace code (with an = one-liner): function are_int (...$args) { return count($args) =3D=3D count(array_filter("is_int", $args)); } So: tl;dr: only in favour if technically not too complicated and doesn't = have the restrictions of a typical language construct. Else: -1.=20 Bob Weinand=