Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79558 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19803 invoked from network); 11 Dec 2014 07:24:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2014 07:24:19 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.171 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.214.171 mail-ob0-f171.google.com Received: from [209.85.214.171] ([209.85.214.171:34094] helo=mail-ob0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 39/42-05320-2A649845 for ; Thu, 11 Dec 2014 02:24:18 -0500 Received: by mail-ob0-f171.google.com with SMTP id uz6so1748491obc.2 for ; Wed, 10 Dec 2014 23:24:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=1xRWzYDFHbkN35koY6j0vJtzX02a5+/jvj0okXA4shM=; b=ZdQJR4RbajluTmh2iw0Apfogm2hCeqsSywxQvzOyKLLcFdPxDoiomPmJbvwAjNZZB0 trGWZvfqE4VPjsDQXsHOuPk1V5MLYUgxCY82u8644BPQ7Lm7OAk3xGFKe1koRW28FMc+ ZlFK5/NOL2nlRnMXkYxmjBqkILWmawHQtPiFRdlURQbjynxUeb+WKDnMm21cx2zgU3FG q5F93pVkl0eQOELFPPugV7C7gCtNhzq165lIWtPvPE8B2eiLRmGr+940sCsTBQ1jtGWd Fv1w4ReADAm2ekleyunQjvVsKKiSzzDRFNP5CXWqmg9YCklWe6N+gZD6C+ZbEyIx36e9 YTWg== X-Received: by 10.202.73.151 with SMTP id w145mr5069870oia.5.1418282655758; Wed, 10 Dec 2014 23:24:15 -0800 (PST) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id mm2sm139078oeb.17.2014.12.10.23.24.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Dec 2014 23:24:15 -0800 (PST) Message-ID: <5489469A.2050100@gmail.com> Date: Wed, 10 Dec 2014 23:24:10 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Josh Watzman , Robert Stoll CC: PHP internals References: <95A581EE-A062-4926-BE44-BCA87FC9B356@fb.com> <000b01d01494$bb1c6520$31552f60$@tutteli.ch> In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Nullsafe calls From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > Take a look at the "short circuit" section where I specifically > address this. It was done to make it easier to reason about in a > side-effect-ful language like PHP. With this behavior, when you see > > $x?->f(g(), h()) I think this is weird magic behavior which should not be part of PHP. If $x is null, there's no object to call f on, and as such f() call is not executed. However, if argument still be evaluated even though the call is never done, this makes no sense at all - why evaluate the arguments if there's nothing to call? Moreover, what if g() and h() actually use $x assuming - quite right, since we're calling the method on it - that $x is not null? Moreover, having code depending on side effect of function call which is not part of the call itself is extremely bad style (i.e., what happens if g() throws exception and h() is never called?) and should not be encouraged. > -- we in fact don't make the method call, but we still prepare > everything as if we were going to, and just decide not to do it at > the last moment. Which, again, makes little sense - if we know there would be no call, why prepare everything and decide at the last moment? It's like you know your flight was cancelled, but you still drive to the airport, pass security, give the baggage to the airline, show up at the gate, wait until the last moment and then - surpries! it's still cancelled! - so you take your baggage back and drive back home. Why would anybody do that? > I feel pretty strongly that this is the correct behavior. It may > sound strange when talking about isolated examples like this, but in It does sound strange. > the real-world code I've seen, it is the least confusing. (I'll see Which real-world code you are talking about? Examples please. -- Stas Malyshev smalyshev@gmail.com