Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96719 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55074 invoked from network); 3 Nov 2016 15:30:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Nov 2016 15:30:05 -0000 Received: from [127.0.0.1] ([127.0.0.1:19374]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id F0/2C-34238-CF75B185 for ; Thu, 03 Nov 2016 10:30:05 -0500 Authentication-Results: pb1.pair.com header.from=contactme@antonydandrea.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=contactme@antonydandrea.com; spf=permerror; sender-id=softfail Received-SPF: error (pb1.pair.com: domain antonydandrea.com from 213.171.216.25 cause and error) X-PHP-List-Original-Sender: contactme@antonydandrea.com X-Host-Fingerprint: 213.171.216.25 exch-smtp-out.livemail.co.uk Linux 2.6 Received: from [213.171.216.25] ([213.171.216.25:53384] helo=exch-2010-smtp-out-02.livemail.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 72/1C-34238-7715B185 for ; Thu, 03 Nov 2016 10:02:16 -0500 Received: by exch-2010-smtp-out-02.livemail.co.uk (Postfix, from userid 500) id A7655A0E8EE; Thu, 3 Nov 2016 15:02:10 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on exch-2010-smtp-out-02.livemail.co.uk X-Spam-Level: X-Spam-Status: No, score=0.0 required=7.0 tests=HTML_MESSAGE autolearn=disabled version=3.3.1 Received: from exch4-ht01.email4.local (mail213-171-216-93.livemail.co.uk [213.171.216.93]) by exch-2010-smtp-out-02.livemail.co.uk (Postfix) with ESMTP id 7DF5AA0E904 for ; Thu, 3 Nov 2016 15:02:10 +0000 (GMT) Received: from EXCH4-MBX03.email4.local ([fe80::68b1:44a6:8919:d50e]) by exch4-ht01.email4.local ([fe80::6024:bc8c:17c0:aa2d%17]) with mapi id 14.03.0319.002; Thu, 3 Nov 2016 15:02:09 +0000 To: "internals@lists.php.net" Thread-Topic: Proposed RFC Thread-Index: AdI13+OSeD2pbTsoTayeD04p0RFabg== Date: Thu, 3 Nov 2016 15:02:08 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [185.53.227.178] Content-Type: multipart/alternative; boundary="_000_A2B4634FB13FB849A1CCA442A9F793304D0615F1exch4mbx03email_" MIME-Version: 1.0 Subject: Proposed RFC From: contactme@antonydandrea.com (Antony D'Andrea) --_000_A2B4634FB13FB849A1CCA442A9F793304D0615F1exch4mbx03email_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, First off, this is my first time e-mailing internals or even thinking about= submitting RFC. Please forgive me if I fail to follow some kind of convent= ion. In PHP 7.0, we were given the Null Coalesce operator. For example: echo $array['key']??"key is not set" would be the same as: echo (isset($array['key'])?$array['key']:"key is not set" This is a great feature, that makes code much cleaner. This works on the principle that "$array['key']" is "NULL". I would like to propose a new feature that is as clean as this but is a sli= ghtly different use case. This would require a new operator (up for discuss= ion, but an early idea is "?!") For example: echo (!is_infinite($n1/$n2)?!0); Would output ($n1/$n2) if it is "true" and 0 if false. Right now, the closest we have to this is ?: operator. The problem with thi= s is that it could get very messy as you still have to do: echo (!is_infinite($n1/$n2)?$n1/$n2:0); I have obviously over simplified the example. You wouldn't have a big probl= em in this case, but if the subject of the function is much longer, it can = become complicated very quickly. Alternatively, a perhaps more general feature would be to just have the sam= e functionality as the Null Coalesce, but with true/false rather than Null/= Not Null. Please let me know if there is something in these ideas or anyway to improv= e them. I should also note that I would need a volunteer to implement this = as my "C" skills are non-existent and I wouldn't have the confidence to del= ve into the the PHP source. Thanks for your time. Best, Antony D'Andrea --_000_A2B4634FB13FB849A1CCA442A9F793304D0615F1exch4mbx03email_--