Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79526 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34175 invoked from network); 10 Dec 2014 16:20:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Dec 2014 16:20:20 -0000 Authentication-Results: pb1.pair.com header.from=php@tutteli.ch; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=php@tutteli.ch; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain tutteli.ch designates 80.74.154.78 as permitted sender) X-PHP-List-Original-Sender: php@tutteli.ch X-Host-Fingerprint: 80.74.154.78 ns73.kreativmedia.ch Linux 2.6 Received: from [80.74.154.78] ([80.74.154.78:60694] helo=hyperion.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 32/C0-29826-3C278845 for ; Wed, 10 Dec 2014 11:20:19 -0500 Received: (qmail 32519 invoked from network); 10 Dec 2014 17:20:15 +0100 Received: from cm56-129-238.liwest.at (HELO RoLaptop) (86.56.129.238) by ns73.kreativmedia.ch with ESMTPSA (AES256-SHA encrypted, authenticated); 10 Dec 2014 17:20:15 +0100 To: "'Josh Watzman'" , "'PHP internals'" References: <95A581EE-A062-4926-BE44-BCA87FC9B356@fb.com> <000b01d01494$bb1c6520$31552f60$@tutteli.ch> In-Reply-To: <000b01d01494$bb1c6520$31552f60$@tutteli.ch> Date: Wed, 10 Dec 2014 17:20:14 +0100 Message-ID: <000c01d01495$2e566180$8b032480$@tutteli.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQLlQZUb/bhxOgCXUpI56Nr+ETsclgEczmegmlXAJ3A= Content-Language: de-ch Subject: AW: [PHP-DEV] [RFC] Nullsafe calls From: php@tutteli.ch ("Robert Stoll") > -----Urspr=FCngliche Nachricht----- > Von: Robert Stoll [mailto:php@tutteli.ch] > Gesendet: Mittwoch, 10. Dezember 2014 17:17 > An: 'Josh Watzman'; 'PHP internals' > Betreff: AW: [PHP-DEV] [RFC] Nullsafe calls >=20 > Hi, >=20 > > -----Urspr=FCngliche Nachricht----- > > Von: Josh Watzman [mailto:jwatzman@fb.com] > > Gesendet: Mittwoch, 10. Dezember 2014 00:08 > > An: PHP internals > > Betreff: [PHP-DEV] [RFC] Nullsafe calls > > > > Hey internals! A useful feature that Hack picked up in the last few > > months are "nullsafe calls", a way of propagating > failure > > forward in a series of chained method calls to the end of the whole > > computation, getting rid of a lot of the > boilerplate in the > > middle. I think the feature would be a good one for PHP as well, so > > I'm submitting this RFC to add it -- you can see > the RFC > > itself for a full discussion of the motivation for the feature, as = well as the feature itself: > > > > https://wiki.php.net/rfc/nullsafe_calls > > > > Josh Watzman > > > > > > -- > > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, > > visit: http://www.php.net/unsub.php >=20 > First of all, I like the RFC, I think as well that it is a useful = feature for PHP and I already have it on my wish list > ;) >=20 > Yet, either I misunderstand the section about short circuiting or I = propose to change the behaviour. >=20 > "If $obj is null, when $obj?->foo(..) executes, the arguments will = still be evaluated." >=20 > IMO that is wrong. It should not evaluate the arguments since the = nullsafe operator (sometimes called "safe navigation" > operator in other languages - which is the better wording IMO, maybe = change it? But that is just a detail) is just syntactic > sugar for making the call only if $bj is not null. So the following: >=20 > $obj =3D null; > $obj?->foo($a, $b); >=20 > should be the same as >=20 > $obj =3D null; > If($obj !=3D=3D null){ > $obj->foo($a, $b); > } >=20 > hence PHP will not complain that $a and $b where not defined. >=20 >=20 > -- > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, = visit: http://www.php.net/unsub.php Appendum: I somehow skipped the section "Prior Art". So I see, that the = different behaviour was on purpose. I do not think it is a clever idea to implement a common concept differently. In = this sense -1 Changing the RFC and implementing it the same way others do +1