Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51970 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89585 invoked from network); 21 Apr 2011 00:58:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Apr 2011 00:58:00 -0000 Authentication-Results: pb1.pair.com header.from=davidkmuir@gmail.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=davidkmuir@gmail.com; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain gmail.com does not designate 208.113.200.5 as permitted sender) X-PHP-List-Original-Sender: davidkmuir@gmail.com X-Host-Fingerprint: 208.113.200.5 caibbdcaaaaf.dreamhost.com Windows 98 (1) Received: from [208.113.200.5] ([208.113.200.5:53004] helo=homiemail-a80.g.dreamhost.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 50/21-24878-6118FAD4 for ; Wed, 20 Apr 2011 20:57:58 -0400 Received: from homiemail-a80.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a80.g.dreamhost.com (Postfix) with ESMTP id E855237A075 for ; Wed, 20 Apr 2011 17:57:21 -0700 (PDT) Received: from [192.168.3.3] (softbank221040106178.bbtec.net [221.40.106.178]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: david@thefourstooges.com) by homiemail-a80.g.dreamhost.com (Postfix) with ESMTPSA id 58BDB37A06F for ; Wed, 20 Apr 2011 17:57:21 -0700 (PDT) Message-ID: <4DAF8105.5060105@gmail.com> Date: Thu, 21 Apr 2011 09:57:41 +0900 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 To: internals@lists.php.net 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> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator From: davidkmuir@gmail.com (David Muir) On 21/04/11 08:56, Arpad Ray wrote: > On Thu, Apr 14, 2011 at 3:05 PM, Hannes Landeholm wrote: >> Some suggested that the ternary if comparison should suppress the notice >> automatically. This would break existing code and also be confusing since >> people expect a ternary if and normal if to work the same way. >> >> Some suggested ?? as an array access operator that suppresses the notice and >> has 3 variants: A: nothing specified - uses null as default, B: has default >> specified, C: returns X if index exists or Y if index doesn't exist. This >> effectively solves the code duplication problem and is a shortcut for saying >> "the array index may or may not exist". >> >> One person said that the relation between ? and ?? and == and === would make >> the operator non-intuitive. Other people disagreed and claimed the opposite. >> >> So basically the discussion now is what exact characters that should be used >> to represent this operator? I really hope we can get this implemented >> quickly... I worked with $_POST yesterday and I could really use that ?? >> operator. > Hi, > > I must say that the prospect of yet more new syntax is scary. It > really looks like Perl, and I wouldn't have the slightest clue what it > meant if I'd missed the release notes. > > I've pined for something like coalesce($_GET['foo'], $defaults['foo'], > 42) for years, and I think that style is far more in keeping with the > PHP ethos, and far more readily understandable than this suggested new > syntax. > > If I've missed some argument against this then please correct me. > > Regards, > > Arpad > What does coalesce() do? If I'm guessing correctly, would proposal #2 that Rune Kaagaard put up solve that for you? https://gist.github.com/909711 Cheers, David