Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51846 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87373 invoked from network); 8 Apr 2011 18:45:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Apr 2011 18:45:48 -0000 Received: from [127.0.0.1] ([127.0.0.1:18561]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 79/D2-65418-CD75F9D4 for ; Fri, 08 Apr 2011 14:45:48 -0400 Authentication-Results: pb1.pair.com smtp.mail=swhitemanlistens-software@cypressintegrated.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=swhitemanlistens-software@cypressintegrated.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain cypressintegrated.com designates 69.28.242.152 as permitted sender) X-PHP-List-Original-Sender: swhitemanlistens-software@cypressintegrated.com X-Host-Fingerprint: 69.28.242.152 rproxy1-a.cypressintegrated.com Windows 2000 SP4, XP SP1 Received: from [69.28.242.152] ([69.28.242.152:1680] helo=rproxy1-a.cypressintegrated.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3A/C2-65418-D455F9D4 for ; Fri, 08 Apr 2011 14:34:54 -0400 Received: from [216.220.106.124] ([192.168.87.152]) by rproxy1-a.cypressintegrated.com (Brand New Heavy v1.0) with ASMTP id RWQ65651; Fri, 08 Apr 2011 14:34:51 -0400 Date: Fri, 8 Apr 2011 14:34:41 -0400 Reply-To: Sanford Whiteman X-Priority: 3 (Normal) Message-ID: <718216446.20110408143441@cypressintegrated.com> To: Matt Pelmear CC: internals@lists.php.net In-Reply-To: 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> <4D9E96B6.6060401@lerdorf.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator From: swhitemanlistens-software@cypressintegrated.com (Sanford Whiteman) > First post here; been watching for a while though. Same here. Here's my take: [1] I don't like ?? / ? because it is disjunctive with =3D=3D=3D / =3D=3D= .. The extra equals sign strengthens equality comparison, while the extra question mark essentially _weakens_ the ternary operator (making it more forgiving). (Sure, a case could be made that an "extra" duplicate operator has no inherent meaning overall, but these two operators seem to be in a similar domain.) [2] I would prefer @?. This makes the error-suppression obvious. But this leads to... [3] ... are we saying that [a] we are still suppressing a deep error or [b] or that an error state does not exist anywhere when you use a special operator? In other words, is it now going to be fully supported to use undefined variables, as long as we always use operators that take them into account? This seems to be inviting criticism from other language fanboys (if we care) since they already hold the non-fatal use of undefined variables in contempt. [4] Strange idea: what about treating the variable as defined after you test it with the special operator, even if you don't specifically assign it a value? So: $varor2 =3D $var1 @?: 2 // $varor2=3D=3D2, no warning because special ternary is used $varor3 =3D $var1 ?: 3 // $varor3=3D3, but no warning because $var1 has been implicitly defined in special expression [5] Sort of the opposite of [4] and continuing the question of [3], what about only letting a variable be special-op-checked once before throwing a warning. So you can suppress (or not throw) the undefined warning once, but it is assumed that you will define the variable in that statement. So this would discourage the continuous use of the same undef var throughout code (which seems like a code smell), while allowing for the real case that you're using the special-op to filter $_REQUEST or whatever -- one time. I haven't really thought about the edges, but thought I'd put those out there. Cheers, Sandy