Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70420 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78278 invoked from network); 26 Nov 2013 17:58:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Nov 2013 17:58:42 -0000 Authentication-Results: pb1.pair.com header.from=pjsturgeon@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pjsturgeon@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: pjsturgeon@gmail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:62255] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/18-39355-051E4925 for ; Tue, 26 Nov 2013 12:58:42 -0500 Received: by mail-lb0-f170.google.com with SMTP id w7so4737647lbi.15 for ; Tue, 26 Nov 2013 09:58:37 -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=EE9reNOh0DWGIF6n4iiMz3kh6n0SEO3OGoauA5uvHPg=; b=pAgbSKWWsPg8VG5b7vXPjfzDUZ14QGYTcVJrCsLuoue8/kWgB0DqBz/ZQenX5lzylk er4BBkE2IIpCYgdaBpHQuubqHxwahT9REz1n4L17jUbOrMqH0onCGBTHLEMamMIgYh65 dx8n6d8jjKWRMEBxU6+PPiphKTuutT1gw+9PQdCkl+4N4/GrGclB+KN9LxShtuEVIScG 8d97vXkH9ujNTFVru3ip6BjMShEpv9/P62HaK/J8SHu6tfQSdBo8wzxgHD6KYaf08B34 FrG4h9sBEREVxREVibrrWL2uvvru940Dh8uHGIo+8DD2JQ4NSrdCuC5dFX+e4lBGNL3L 99ig== MIME-Version: 1.0 X-Received: by 10.112.146.200 with SMTP id te8mr5603962lbb.32.1385488717864; Tue, 26 Nov 2013 09:58:37 -0800 (PST) Received: by 10.114.217.231 with HTTP; Tue, 26 Nov 2013 09:58:37 -0800 (PST) In-Reply-To: References: Date: Tue, 26 Nov 2013 12:58:37 -0500 Message-ID: To: Etienne Kneuss Cc: Chris London , Paul Dragoonis , Mats Lindh , "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [Proposal] Modification to ?: functionality From: pjsturgeon@gmail.com (Philip Sturgeon) On Tue, Nov 26, 2013 at 12:54 PM, Etienne Kneuss wrote: > On Tue, Nov 26, 2013 at 6:48 PM, Chris London wrote: > >> On Tue, Nov 26, 2013 at 10:41 AM, Paul Dragoonis > >wrote: >> >> > >> > >> > >> > On Tue, Nov 26, 2013 at 4:58 PM, Chris London wrote: >> > >> >> 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'; >> >> >> >> >> >> > >> > We can't change the behaviour of ?: that ship has already sailed, we'll >> > just be hurting existing codebases on upgrading and more user education >> is >> > required to understand non-visual changes in syntax like this, lets try >> to >> > learn from our mistakes by not changing 'behaviour' anymore. >> > >> > An alternative syntax that is similar and not ugly would be good since >> the >> > ?: behaviour was broken from the start since you still need to run >> isset() >> > before running ?: which was the problem we tried to solve in the first >> > place but it just didn't happen. >> > >> > I don't like the @ symbol it's too different from what's already there on >> > the ternary logic. >> > >> >> My reason for the @ symbol was that it's already used to suppress errors so >> to me it seems like it could be interpreted as a suppressed ternary but I'm >> open to other suggestions. >> >> >> > >> > Proposal: $foo = $arr['value'] ?:: ""; >> > >> >> I'd be fine with this choice. >> > > I don't see any value in adding yet another operator for this, we already > support this through: > > $foo = @$arr['value'] ?: ""; > > > > > -- > Etienne Kneuss > http://www.colder.ch We probably shouldn't pretend that using @ to help set default values is a good idea.