Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51833 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99283 invoked from network); 8 Apr 2011 05:01:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Apr 2011 05:01:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.220.170 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.220.170 mail-vx0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:63231] helo=mail-vx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CB/03-04528-BB69E9D4 for ; Fri, 08 Apr 2011 01:01:48 -0400 Received: by vxb40 with SMTP id 40so2698208vxb.29 for ; Thu, 07 Apr 2011 22:01:45 -0700 (PDT) Received: by 10.52.76.195 with SMTP id m3mr2503680vdw.130.1302238905040; Thu, 07 Apr 2011 22:01:45 -0700 (PDT) Received: from [192.168.1.5] (cpe-66-108-47-56.nyc.res.rr.com [66.108.47.56]) by mx.google.com with ESMTPS id s33sm586162vcr.29.2011.04.07.22.01.43 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 07 Apr 2011 22:01:44 -0700 (PDT) Message-ID: <4D9E96B6.6060401@lerdorf.com> Date: Fri, 08 Apr 2011 01:01:42 -0400 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 MIME-Version: 1.0 To: Stas Malyshev CC: Matthew Weier O'Phinney , "internals@lists.php.net" References: <4D950434.3060704@yahoo.com.au> <4D9E0543.1080600@lerdorf.com> <69.82.36433.EC33E9D4@pb1.pair.com> <4D9E34C4.5000406@lerdorf.com> <4D9E429B.20503@sugarcrm.com> In-Reply-To: <4D9E429B.20503@sugarcrm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator From: rasmus@lerdorf.com (Rasmus Lerdorf) On 04/07/2011 07:02 PM, Stas Malyshev wrote: > Hi! > >>> $value = isset($a[$key]) ? $a[$key] : 'Not set'; >>> >>> which is exactly the situation I had before it was introduced. >> >> Not sure why you would have that expectation. The long ternary doesn't >> do that, and there is nothing about the short ternary that changes that. > > It is true, however I think the amount of boilerplate code produces by > this paradigm is staggering, and it's about time we fixed that. We had a > chance of doing it with ?: but for one reason or another it was passed, > but the need is still there. I think actually the idea of "expr ?? > expr2", meaning (isset($expr)?$expr:$expr2) is not bad. Anybody sees any > holes in it? > And yes, I wouldn't be disappointed too much if ?: didn't generate > notices either. With modern IDEs times when it helped catch typos are > mostly gone, and now these warnings are just a very annoying reason to > write boilerplate code. I'm not against coming up with a cleaner no-warning mechanism for this. I was just responding to the idea that the intent of ?: was to solve this. It never was. We need to be careful about changing the beahviour of existing operators. -Rasmus