Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51914 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33298 invoked from network); 16 Apr 2011 01:42:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Apr 2011 01:42:16 -0000 Authentication-Results: pb1.pair.com header.from=simpleshot@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=simpleshot@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: simpleshot@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-ew0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:37515] helo=mail-ew0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2E/D4-13342-7F3F8AD4 for ; Fri, 15 Apr 2011 21:42:15 -0400 Received: by ewy2 with SMTP id 2so906538ewy.29 for ; Fri, 15 Apr 2011 18:42:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=cBB7X/TVTq+Bi1VHCC8twJIi1Llgh9oZ4eJgGNPI8/g=; b=wKVfcGkZp1faw5zqyjqkBued1jcdrB4glQRmbmfk4Crhh74Ehm0pSBnlo4y916qkGg dEzTgKAIRgUijkZbEaUH9PQp2wHLInSQkNPrIIW+34vQ7m0E2RSd+bP1o33SUlLvClz2 Rgoq7jEg3Okat2T/C87OjTGtLC0OdMfxQ6DC4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=DAcbmVQBlJknbzeI5M4b2ukHZa2p3WU3spupoa26uDfhFvpUzivMdJf1Docb4l5zja bebyDg6oN75LMp0qs5nhbfvdkz7jCUmcrGGH5Am4B9WEROCwr/ij85uRGcYa46fAVZVf 1TCXYVd3gAIxVl6IUyHeOrzepTweZwis+bHgw= MIME-Version: 1.0 Received: by 10.213.103.203 with SMTP id l11mr3076406ebo.55.1302918132007; Fri, 15 Apr 2011 18:42:12 -0700 (PDT) Received: by 10.213.10.13 with HTTP; Fri, 15 Apr 2011 18:42:11 -0700 (PDT) In-Reply-To: <4DA8E6D9.5080107@yahoo.com.au> References: <4D9E96B6.6060401@lerdorf.com> <718216446.20110408143441@cypressintegrated.com> <4DA0E71C.9030008@gmail.com> <4DA63ED8.4080402@yahoo.com.au> <4DA6F2BC.10706@yahoo.com.au> <4DA6FB03.9040404@yahoo.com.au> <4DA8E6D9.5080107@yahoo.com.au> Date: Fri, 15 Apr 2011 21:42:11 -0400 Message-ID: To: PHP Development Content-Type: multipart/alternative; boundary=001636d346406e028104a0ff4494 Subject: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator From: simpleshot@gmail.com (Adam Richardson) --001636d346406e028104a0ff4494 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Apr 15, 2011 at 8:46 PM, Ben Schmidt wrote: > There was also my suggestion of a "checked ternary" operator [see my >> previous email in this thread.] Backwards compatible, practical, and >> simple. >> > > It doesn't address the main issues of code duplication and nullness > checking, IMHO, so isn't a contender. Even though it's simple and > compatible, it is only practical in a handful of cases. > I believe describing nullness checking as a "main" issue is a rather strong assessment. David's original message and patch (and several of the suggestions in this thread) speak to the issues with boilerplate code needed to avoid warnings elicited when accessing a non-existant array key. This is the type of code that you tend to see out in the wild that David and others have cited as a pain: $var = (isset($arr['key'])) ? $arr['key'] : 'empty'; Additionally, it might not be as succinct as you prefer, but surely $var = $arr['key'] ?? : 'empty'; is a significant improvement over the current means and does in fact remove redundant code. Now, perhaps there are other options that are better. This is an interesting dialogue to follow, and I've enjoyed the reading. However, after viewing the other proposals thus far, my preference would still be for the checked ternary operator. Respectfully, Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com --001636d346406e028104a0ff4494--