Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89349 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15836 invoked from network); 23 Nov 2015 20:16:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Nov 2015 20:16:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=shadda@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=shadda@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.44 as permitted sender) X-PHP-List-Original-Sender: shadda@gmail.com X-Host-Fingerprint: 209.85.220.44 mail-pa0-f44.google.com Received: from [209.85.220.44] ([209.85.220.44:33494] helo=mail-pa0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C0/FA-47837-81473565 for ; Mon, 23 Nov 2015 15:16:24 -0500 Received: by pabfh17 with SMTP id fh17so207349023pab.0 for ; Mon, 23 Nov 2015 12:16:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=MTtCedqZnHyZwiiiY/K1tTjYv8pdRVVz9f3I4LGWrwA=; b=fgGZBXCCtm21OrRoLFbxFytfiIkbJIUMLjjmebYsH8mXz+eBBjFa0VPVSakNydabz8 xKpHOaWKszc5GSFFdCl9v2LzJKF0jBeKrJsy+LDfWNIfnj9jE4UfVSETDDZ8s3aoVSyw GlPJecs7FPCUW6X1iwgLceoauNbcme1bLxm3a0JmZr7/RQGjbFI74Cdn0i33XV3UsQg4 qigCTIyJPRweYplyXnHrdzGstmCMoN3Z1VRN7FbNsO4p7OjnvbfTdH7OHnWosliCfQWk zAMUZ3vXpzovCO39kqa1DVtXEfqB1Jab8Pm+cl3T8yheEttN/UupjODmX608s5KULzF9 yOPg== X-Received: by 10.68.244.35 with SMTP id xd3mr37978037pbc.1.1448309781752; Mon, 23 Nov 2015 12:16:21 -0800 (PST) Received: from [192.168.0.18] (70-36-238-3.dsl.static.fusionbroadband.com. [70.36.238.3]) by smtp.gmail.com with ESMTPSA id 68sm3355944pfq.37.2015.11.23.12.16.20 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Nov 2015 12:16:21 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.0 \(3094\)) In-Reply-To: Date: Mon, 23 Nov 2015 12:16:19 -0800 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <7641479E-65DD-4B5F-B1E5-2A0D4E91D69B@gmail.com> References: <4D5D4A6D-1E94-4893-B1DF-7A8C616C871A@gmail.com> <20.F5.23339.A9822565@pb1.pair.com> <457D19DF-746D-40D0-BA0F-7064D265901E@gmail.com> To: Phil Sturgeon X-Mailer: Apple Mail (2.3094) Subject: Re: [PHP-DEV] PHP7 Coalesce operator From: shadda@gmail.com (shadda) It=E2=80=99s not hate, I happen to like that ?? was added. I=E2=80=99m = not raising a concern nor asking for a change in its behavior. Rather, = I=E2=80=99m asking for another, similar operator that=E2=80=99s based on = truth-evaluation (with PHP=E2=80=99s tender, loving conversion rules = baked in), in *addition* to ?? which tests for null/undefined = exclusively. =20 > On Nov 23, 2015, at 12:08 PM, Phil Sturgeon = wrote: >=20 > On Mon, Nov 23, 2015 at 9:52 AM, shadda wrote: >> Er, that should read, =E2=80=9Canything non (null, false, undefined) = is true=E2=80=9D >>=20 >>> On Nov 23, 2015, at 11:51 AM, shadda wrote: >>>=20 >>> Hey, thanks for responding. >>>=20 >>> However, I still think that misses the point, or at least the true = utility of what I=E2=80=99m proposing. >>>=20 >>> In practice, you can ignore E_NOTICE and php will happily treat null = and !isset() as the same thing in *most* cases, so that=E2=80=99s not a = good indicator of truthiness. >>>=20 >>> Basically in ECMA, anything non-null, false, or undefined is true. = PHP is very similar in that regard, but our reliance on E_NOTICE to = (ahem) enforce isset() checks is why, I assume, we=E2=80=99re = introducing the ?? operator to begin with. >>>=20 >>> I just think it=E2=80=99d be nice to have a small variation on this = feature that was less concerned with a (defined|null) semantic and more = in keeping with PHP=E2=80=99s overall handling of implicit type = conversion in expressions. >>>=20 >>> Does that make more sense? >>>=20 >>>> On Nov 22, 2015, at 12:41 PM, Andrea Faulds wrote: >>>>=20 >>>> Hi, >>>>=20 >>>> shadda wrote: >>>>> I had a question-suggestion based around the cool new operator = we=E2=80=99re getting in PHP7, the ?? operator, which as I understand it = is the functional equivalent to perl=E2=80=99s // operator; in that they = both test for whether or not a variable is defined, rather than it=E2=80=99= s truthiness. >>>>=20 >>>> This is not strictly correct. Though something of a misnomer, the = 'null coalesce operator' checks if a variable doesn't exist, but also = that it is not null, i.e. it functions like isset(). >>>>=20 >>>> Thanks. >>>>=20 >>>> -- >>>> Andrea Faulds >>>> http://ajf.me/ >>>>=20 >>>> -- >>>> PHP Internals - PHP Runtime Development Mailing List >>>> To unsubscribe, visit: http://www.php.net/unsub.php >>>>=20 >>>=20 >>=20 >>=20 >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >>=20 >=20 > Ignoring E_NOTICE is generally considered bad practice by many, and > turning them off just to use ternaries instead of null coalesce (a > feature we already have) doesn't seem like a benefit. >=20 > The ?? is used the same as "a =3D b || c" in Ruby or JS. Doing that in > PHP wouldn't work well as || works a bit differently, so ?? is used > instead, just like C and Swift. >=20 > Basically... it's all good. And even if you hate it you're months too > late to raise a concern. :)