Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70404 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49470 invoked from network); 26 Nov 2013 15:15:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Nov 2013 15:15:47 -0000 Authentication-Results: pb1.pair.com header.from=mats.lindh@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=mats.lindh@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.172 as permitted sender) X-PHP-List-Original-Sender: mats.lindh@gmail.com X-Host-Fingerprint: 209.85.223.172 mail-ie0-f172.google.com Received: from [209.85.223.172] ([209.85.223.172:38092] helo=mail-ie0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8D/02-39355-12BB4925 for ; Tue, 26 Nov 2013 10:15:47 -0500 Received: by mail-ie0-f172.google.com with SMTP id qd12so9645315ieb.3 for ; Tue, 26 Nov 2013 07:15:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=H7Lnw8tuXUitHp4UG+alfpOKn92ZTDTCsYdi6dEv7qw=; b=u+3q2YWT/XFauXICUI1H+88/9OokKVcN261+NcMkFCxlEYSQccCV5kuD4rpAkwi0z7 ItRqEoSeRTwCzHJqc8GTa2cYWOFNEYGLRctHhSL26Qr9WUd7Ar/msta3ukzvfzqJu1FT 3hSrDmRYQkssq5kM/sCLUvPAhksCsBLq161oGWkDLmycIjEq0FDw03BJwvxM2xajHHFi bxzEa8Zp8HBV1UaFSf1i+ghZNp+YG8ZHDc9ktHjddYcgBuh6VVdMjdRqhijNX8nN/dVo yaTAzQjOpF3FssNemuI5HIyVcj1YsgZ65mLL45DR7QVvadPjZwDMOZhJHndVaXkEA2LO CI4Q== MIME-Version: 1.0 X-Received: by 10.50.153.50 with SMTP id vd18mr17297818igb.6.1385478942703; Tue, 26 Nov 2013 07:15:42 -0800 (PST) Received: by 10.50.126.37 with HTTP; Tue, 26 Nov 2013 07:15:42 -0800 (PST) In-Reply-To: References: Date: Tue, 26 Nov 2013 16:15:42 +0100 Message-ID: To: Chris London Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e013a009e398e0804ec15f41a Subject: Re: [PHP-DEV] [Proposal] Modification to ?: functionality From: mats.lindh@gmail.com (Mats Lindh) --089e013a009e398e0804ec15f41a Content-Type: text/plain; charset=ISO-8859-1 On Tue, Nov 26, 2013 at 3:43 PM, Chris London wrote: > I believe these two statements are functionally equivalent: > > $foo = $foo ? $foo : 'default'; > > $foo = $foo ?: 'default'; > They are. I would like to change it so it also checks for isset() so I propose the > following would be functionally equivalent: > > $foo = isset($foo) && $foo ? $foo : 'default'; > > $foo = $foo ?: 'default'; > The would break the assumption that a reference to an uninitialized value would generate a notice, unless explicitly handled in the logic. While I also would like to have something similar to ?: to handle default values for array keys, etc., this would change a fundamental assumption that as been in place for many years now. I'm not sure if that's a BC break that would be acceptable this late. An alternative operator may be more suitable. The change proposed has also been discussed several times since the implementation of ?:. See the ifsetor-RFC: https://wiki.php.net/rfc/ifsetor It also contains links to the discussion around the feature back then. --mats --089e013a009e398e0804ec15f41a--