Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79574 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63605 invoked from network); 11 Dec 2014 15:58:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2014 15:58:09 -0000 Authentication-Results: pb1.pair.com header.from=guilhermeblanco@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=guilhermeblanco@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.176 as permitted sender) X-PHP-List-Original-Sender: guilhermeblanco@gmail.com X-Host-Fingerprint: 209.85.223.176 mail-ie0-f176.google.com Received: from [209.85.223.176] ([209.85.223.176:63404] helo=mail-ie0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/80-58820-01FB9845 for ; Thu, 11 Dec 2014 10:58:08 -0500 Received: by mail-ie0-f176.google.com with SMTP id tr6so5048670ieb.21 for ; Thu, 11 Dec 2014 07:58:05 -0800 (PST) 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=EK64cZkC49D77LXudU0TApVVOjhMIlD/klws+uTdzas=; b=tuUoSdk8ch+rUvYJVn8AJBVE+Q2dsItejAor5intqgAXzhQcgpWQ5XVRkVleLIiSPf 3HPo/XOnjYWTHiBF35KhRtc/yvRtuOj+bnnbz0H/RDizCMssaBlKD7lSMKmRjnZssgom 4m/8p0e2POBee53KA3t3k24qLP2fqi7ihno+stgfQA7zR3hzdNZv3kejUksKSPoLnZ0X Vtv4zJ+dlKXADthUzN6+IRylqh2xNgp1SonKe3V9bHmwADn72HaCYTsmSUqcjlSziUri ILpDV7eFP7SPuV2h4bxBZ2eGMt/DVcY2gn+USrxokYKh806Ykvi0dGQDxMW0uekK9Ezi hy6Q== X-Received: by 10.107.135.211 with SMTP id r80mr10392820ioi.67.1418313484865; Thu, 11 Dec 2014 07:58:04 -0800 (PST) MIME-Version: 1.0 Received: by 10.64.238.75 with HTTP; Thu, 11 Dec 2014 07:57:44 -0800 (PST) In-Reply-To: <54894936.9030003@gmail.com> References: <95A581EE-A062-4926-BE44-BCA87FC9B356@fb.com> <9230CB24-22FC-4A0E-A9D5-F02523B65A02@ajf.me> <54894936.9030003@gmail.com> Date: Thu, 11 Dec 2014 10:57:44 -0500 Message-ID: To: Stanislav Malyshev Cc: Andrea Faulds , Josh Watzman , PHP internals Content-Type: multipart/alternative; boundary=001a113ed20a722a2c0509f2d70c Subject: Re: [PHP-DEV] [RFC] Nullsafe calls From: guilhermeblanco@gmail.com ("guilhermeblanco@gmail.com") --001a113ed20a722a2c0509f2d70c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, Not trying to demerit the proposal, but accepting ?-> and black magic just seems wrong, very wrong. You need to write defensive code, not rely on the language to do that for you. []s, On Thu, Dec 11, 2014 at 2:35 AM, Stanislav Malyshev wrote: > Hi! > > > First, how is this substantially different from catching an > > exception? With Nikita=E2=80=99s Exceptions in the Engine RFC > > (https://wiki.php.net/rfc/engine_exceptions_for_php7), something like > > this would be possible: > > > > try { return $foo->bar()->qux()->elePHPant()->dance(); } catch > > (EngineException $e) { return NULL; } > > This actually is not a good code. Exceptions should not be used for > something that is expected and normal, they should rather be used for > situations where you code does something you could not predict. > Programming for exceptions is usually bad style, and designing code flow > expecting exceptions is usually bad idea. So I'd actually prefer being > able, like, say, in Groovy, to say "try to call this long chain of > whatever, but if it doesn't work out, just give me null". Of course, it > is not for carefully controlled code with error reporting, but for some > prototype code dealing with dirty data I found such shortcuts be rather > helpful. I'd like PHP to be more Groovy and less Java, in other words ;) > > > Second, not short-circuiting is rather unintuitive. I think most > > people would expect it to short-circuit. Note that ?? and isset() > > short-circuit, so this would be inconsistent with existing > > NULL-checking operators. So why, then, are you proposing that it > > should not short-circuit? Is there some obscure case that this makes > > easier? If anything, I=E2=80=99d expect that short-circuiting is the mo= re > > useful behaviour. For example, take the following hypothetical line > > of code: > > > > $elePHPantParty->danceClub?->addToDanceFloor($elePHPantPool->remove()); > > I agree, for this feature I think it is a must that it would have no > magic like evaluating code way past the first null in ?-> chain. As soon > as there's null on the left of ?->, we should be done and return null, > it should work just like the if would work. In fact, it can even compile > to the same code as if() would. > -- > Stas Malyshev > smalyshev@gmail.com > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 Guilherme Blanco MSN: guilhermeblanco@hotmail.com GTalk: guilhermeblanco Toronto - ON/Canada --001a113ed20a722a2c0509f2d70c--