Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61430 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49738 invoked from network); 18 Jul 2012 19:21:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jul 2012 19:21:46 -0000 Authentication-Results: pb1.pair.com header.from=ww.galen@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ww.galen@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.182 as permitted sender) X-PHP-List-Original-Sender: ww.galen@gmail.com X-Host-Fingerprint: 209.85.212.182 mail-wi0-f182.google.com Received: from [209.85.212.182] ([209.85.212.182:59294] helo=mail-wi0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DA/80-46800-8CC07005 for ; Wed, 18 Jul 2012 15:21:45 -0400 Received: by wibhq12 with SMTP id hq12so1415943wib.11 for ; Wed, 18 Jul 2012 12:21:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=nq8CdRqvY8QXvUO/RMkQ758Mn6Uc1iEUGvb251Kbdco=; b=QnkU+aHgjXSSyRxmpO+T24N6DK04/EAUhSbq5awBr8ySe1Qhlo2PELvrcAtbBAj6n4 u6RA2hIrPxyrEy4jhbayZ40+agwRKPDaFiiBr2oGOm41is+S7qWY6KNxtm1ECiQKQFY4 QRXiND+XOZRReUBa5Mku0dvss+l9uewoBDefJF1H0h1dCyxcneYhQncvh7WQzUsTx3/p FqwfBb/cGJz3Vz1JRMrsoRJr2DoROQ6bouNPUQ9gWwGixOPVcyKjNHKjGW9sQpp9rnKd 7VeSncBfZfjgxc+n8U2n3pGqJmIrQLgz0kBt1nu/HmRk3dqA4otRxLVpw7lI8e8v3ttZ rrnA== Received: by 10.180.106.97 with SMTP id gt1mr9032371wib.5.1342639301903; Wed, 18 Jul 2012 12:21:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.41.40 with HTTP; Wed, 18 Jul 2012 12:21:01 -0700 (PDT) In-Reply-To: References: Date: Wed, 18 Jul 2012 12:21:01 -0700 Message-ID: To: Anthony Ferrara Cc: Rafael Dohms , PHP internals Content-Type: multipart/alternative; boundary=f46d04428066a6c5fc04c51f9211 Subject: Re: [PHP-DEV] Implicit isset in ternary operator From: ww.galen@gmail.com (Galen Wright-Watson) --f46d04428066a6c5fc04c51f9211 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Jul 18, 2012 at 7:20 AM, Anthony Ferrara wrote: > > On Wed, Jul 18, 2012 at 10:15 AM, Rafael Dohms >wrote: > > > [...] > > > > This is basically because the ternary operator does not do a internal > > implicit isset, only an empty. > > > > It does not do an empty. Empty would avoid notices as well. All it does is > an implicit bool cast... > > > > Does this seem like a possible improvement we can work on? Anyone > > interested in championing the change? > > > > I like it in principle. My only concern is *why* wasn't it done this way in > the first place... Is there a reason? > It changes the semantics. If the variable is set to a falsey value and ?: uses an implicit isset, the value of the expression will be the falsey value. $config['width'] = '' $width = $config['width'] ?: 300 # $width == '' If !empty were used instead of isset, you could preserve semantics ($a ?: dflt = !empty($a) ? $a : dflt). --f46d04428066a6c5fc04c51f9211--