Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77092 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43925 invoked from network); 7 Sep 2014 12:26:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Sep 2014 12:26:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.207 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.207 imap2-2.ox.privateemail.com Received: from [192.64.116.207] ([192.64.116.207:54612] helo=imap2-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 23/82-12208-ADE4C045 for ; Sun, 07 Sep 2014 08:26:03 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 23F4A8C007B; Sun, 7 Sep 2014 08:25:59 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap2.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap2.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id sC7jwWGKt8hF; Sun, 7 Sep 2014 08:25:58 -0400 (EDT) Received: from oa-res-27-90.wireless.abdn.ac.uk (oa-res-27-90.wireless.abdn.ac.uk [137.50.27.90]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 6A9488C0075; Sun, 7 Sep 2014 08:25:57 -0400 (EDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: Date: Sun, 7 Sep 2014 13:25:53 +0100 Cc: Pierre Joye , PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Sherif Ramadan X-Mailer: Apple Mail (2.1878.6) Subject: Re: [PHP-DEV] [RFC] Implicit isset() in Shorthand Ternary Operator From: ajf@ajf.me (Andrea Faulds) On 7 Sep 2014, at 13:22, Sherif Ramadan wrote: > I've played around with this branch for a bit and seems reasonable, = passes > the tests, and doesn't seem to have any serious issues/memories leaks > AFAICT. There=92s actually a quite serious issue just now, which is that it = evaluates the first operand twice if it=92s not empty. This is because = $a ?: $b is expanded to empty($a) ? $b : $a, such that if you did = something which mutates state in there, it=92d happen twice. This is = obviously not good, and I=92m going to figure out how to fix this. > I can't stress enough, however, how important it is for us to avoid > inconsistencies in behavior between various forms of syntax. This is = often > something users complain of as often they complain about not getting = such > features. So let's make ternary consistent before we implement yet = another > oddity in PHP (half-assed and ill designed). >=20 > I don't actually agree with the premise that ternary should wrap the = first > operand in empty() to begin with, but if this is what people want, = fine. > Let's just do it right. >=20 > And as Rasmus mentioned in the PR, make the documentation very = _cleary_ if > it gets accepted. Yeah, I=92ll be sure to make it crystal clear that they aren=92t quite = the same. FWIW, it=92s not our only shorthand which differs in behaviour. For = example, ++ and +=3D 1 are NOT the same, though I=92d love to fix that = particular inconsistency. -- Andrea Faulds http://ajf.me/