Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89344 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7754 invoked from network); 23 Nov 2015 19:51:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Nov 2015 19:51:18 -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.49 as permitted sender) X-PHP-List-Original-Sender: shadda@gmail.com X-Host-Fingerprint: 209.85.220.49 mail-pa0-f49.google.com Received: from [209.85.220.49] ([209.85.220.49:33426] helo=mail-pa0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E8/39-47837-53E63565 for ; Mon, 23 Nov 2015 14:51:18 -0500 Received: by pabfh17 with SMTP id fh17so206740238pab.0 for ; Mon, 23 Nov 2015 11:51:15 -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=0aObJ553bS00+5T2l1peATOOrvUhoT0eDtvLHSCIxN8=; b=G0BxaEPyUWcl8gzuerBdQz1DEZTwHg9pfX7ZYiMymH31zI3N8wjfd5zzSW5CikJucX ofaTF9ph9J6SeYg/mRIV5KvKGKi2o+Vcq7DpL00WnejXN1vVlIvpn1koUIAOF6V3y+5g YwphtCMkmWLz/FPVYgjaLaARpm1x/EcDSifWtd4TM9UdJxqUyQxiVNR1QiXsn8sLz6zT QesX0CfCcA/fgsMKipKjaBeItyC+XM7NKK7sHTQb9zYOnGXaxW5BGv0A5aWBMcmOQvte CL8GM4r+58TH+1Ucgm04zHz2NkvkabHgR7BNGCZXYrE8aDEuQ+n/zxWZeoFFpvA81eRH yZ6w== X-Received: by 10.98.14.15 with SMTP id w15mr17999643pfi.145.1448308274978; Mon, 23 Nov 2015 11:51:14 -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 bz1sm11514661pab.20.2015.11.23.11.51.13 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Nov 2015 11:51:14 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.0 \(3094\)) In-Reply-To: <20.F5.23339.A9822565@pb1.pair.com> Date: Mon, 23 Nov 2015 11:51:12 -0800 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <4D5D4A6D-1E94-4893-B1DF-7A8C616C871A@gmail.com> <20.F5.23339.A9822565@pb1.pair.com> To: Andrea Faulds X-Mailer: Apple Mail (2.3094) Subject: Re: [PHP-DEV] PHP7 Coalesce operator From: shadda@gmail.com (shadda) Hey, thanks for responding. However, I still think that misses the point, or at least the true = utility of what I=E2=80=99m proposing. 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? > 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 > --=20 > Andrea Faulds > http://ajf.me/ >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20