Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70410 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62292 invoked from network); 26 Nov 2013 16:58:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Nov 2013 16:58:10 -0000 Authentication-Results: pb1.pair.com header.from=me@chrislondon.co; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@chrislondon.co; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain chrislondon.co does not designate 209.85.212.169 as permitted sender) X-PHP-List-Original-Sender: me@chrislondon.co X-Host-Fingerprint: 209.85.212.169 mail-wi0-f169.google.com Received: from [209.85.212.169] ([209.85.212.169:34004] helo=mail-wi0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E3/94-39355-123D4925 for ; Tue, 26 Nov 2013 11:58:09 -0500 Received: by mail-wi0-f169.google.com with SMTP id hm6so6156228wib.2 for ; Tue, 26 Nov 2013 08:58:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=o2GF91uaGRW9lGcDKvdYbgYqs8p3aZvQROrp2Lb/cus=; b=ZUiXVpJiCDoMjmK9XYgMGjHATPUVnZ+0JHO0RZrtYCR1chk5hTZ7Ow5Tuif6ERHpel D7fvhmA1ekvtGIuYzRSkjKf14/p/qqw5tPxCT5rC184IMaRXpb/8ctEw8fRdGArRvu4C D3H5NM3MwL3Eo74jXrk7FcFkT+fICo9t1DTm1c9up6QK390aE2JbcV1Ei7IwYTKGLO1m /RLN/TzaZyNYr2w9wxSh4waHk49L+RTAkef1XkncrmQXG3kP7tx5WW0qBSp4Hr2BBH63 RUBYfIHqimSO8oIyXEgE2JRm8ubLzNRCzOGb6WG8vTZAHs+uZdSrUlMQDaNI5UFqHg0A y64g== X-Gm-Message-State: ALoCoQkWEFePM7WH6iEqA2ZYLSIoJlNyM9ZaVDbPeDmTAhndMNG4u7+Tt2XXOBM5boLWyzacSk0Z MIME-Version: 1.0 X-Received: by 10.180.221.106 with SMTP id qd10mr18735676wic.57.1385485086728; Tue, 26 Nov 2013 08:58:06 -0800 (PST) Received: by 10.217.153.135 with HTTP; Tue, 26 Nov 2013 08:58:06 -0800 (PST) X-Originating-IP: [66.219.207.210] In-Reply-To: References: Date: Tue, 26 Nov 2013 09:58:06 -0700 Message-ID: To: Mats Lindh Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1134ccb26fc93c04ec1762fc Subject: Re: [PHP-DEV] [Proposal] Modification to ?: functionality From: me@chrislondon.co (Chris London) --001a1134ccb26fc93c04ec1762fc Content-Type: text/plain; charset=ISO-8859-1 On Tue, Nov 26, 2013 at 8:15 AM, Mats Lindh wrote: > 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. > What do you think about using: $foo = $foo @: 'default'; and possibly $foo @= 'default'; > > 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 > --001a1134ccb26fc93c04ec1762fc--