Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98164 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32531 invoked from network); 4 Feb 2017 04:38:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2017 04:38:58 -0000 Authentication-Results: pb1.pair.com header.from=php-lists@koalephant.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=php-lists@koalephant.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain koalephant.com designates 206.123.115.54 as permitted sender) X-PHP-List-Original-Sender: php-lists@koalephant.com X-Host-Fingerprint: 206.123.115.54 mail1.25mail.st Received: from [206.123.115.54] ([206.123.115.54:34500] helo=mail1.25mail.st) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4D/CD-38491-0EA55985 for ; Fri, 03 Feb 2017 23:38:57 -0500 Received: from [10.0.1.57] (unknown [183.89.47.214]) by mail1.25mail.st (Postfix) with ESMTPSA id F170360462; Sat, 4 Feb 2017 04:38:46 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) X-Mailer: iPhone Mail (13G36) In-Reply-To: <22B18CB2-0383-4D4D-9B55-91A748725AC9@trowski.com> Date: Sat, 4 Feb 2017 11:38:37 +0700 Cc: internals , ilija.tovilo@me.com Content-Transfer-Encoding: quoted-printable Message-ID: <77287A6A-C3E9-4C93-A1F2-2899DAEA8738@koalephant.com> References: <19.45.38491.677D4985@pb1.pair.com> <611b72db-420f-4963-ab92-0ddf977a0aaa@Spark> <9AF0D2F6-D668-418C-8B96-3320D9D245ED@trowski.com> <5722B01C-A621-4C13-B34B-383B0D9753F9@koalephant.com> <22B18CB2-0383-4D4D-9B55-91A748725AC9@trowski.com> To: Aaron Piotrowski Subject: Re: [PHP-DEV] [RFC][Discuss] Arrow Functions From: php-lists@koalephant.com (Stephen Reay) Hi Aaron, Sent from my iPhone > On 4 Feb 2017, at 10:33, Aaron Piotrowski wrote: >=20 >=20 >> On Feb 3, 2017, at 9:06 PM, Stephen Reay wrote= : >>=20 >>=20 >>> On 4 Feb 2017, at 07:25, Aaron Piotrowski wrote: >>>=20 >>> $callback =3D |int|float $x| =3D> $x ** 2; >>=20 >> Forget the parser, you're giving my eyes diabetes trying to read that. >=20 > I absolutely agree that it's terrible=E2=80=A6 the point is that types (ev= en potential future union types) can be used with short closures, but it cer= tainly doesn't mean they should be. I don't think confusion with a non-exist= ent and non-recommended way of coding should be a reason against a particula= r syntax. Using type hints is a part of the language. It even has benefits that I can a= bsolutely see being used here: array_map(function(Foo $x) =3D> $x->bar());=20 If Foo is a class/interface with a method of bar, your IDE can know that it'= s a valid method to call. That of course is in addition to the benefit of getting useful type errors f= rom PHP itself. >=20 >> As has been said before, PHP is relatively verbose compared to other lang= uages. That makes it slightly more characters to type, but it also makes it a= bsolutely clear what is happening. >=20 > Using `function` IMO makes it more likely to confuse a short closure with a= regular closure. Reusing the `function` keyword with different semantics ma= y result in some confusion. >=20 So we should instead use syntax already used for bit wise OR, and further co= nfuse the situation when the function has no parameters and reusing the logi= cal OR operator. Brilliant. This is still a function, it has slightly different semantics, just like how= a regular function, a class instance method and a static class method have s= lightly different semantics: we still use the function keyword for all of th= ose. The static keyword is used for functions, class static properties, static va= riables and even static closures: it's semantics are slightly different for e= ach case but we reuse the same keyword. >> As Niklas said, all ambiguity/clarity issues are solved by using "functio= n", at the cost of 6 characters. >>=20 >> Suggesting that a search for arrow functions will be easier with and then using grep (which could also easily match arr= ow functions using "function") as your example search seems odd to me. >=20 > I never suggested this, Bj=C3=B6rn Larsson did. Any of the possibilities m= entioned in this thread could easily be searched. Apologies I meant to quote the earlier message/author but I'm on a phone and= forgot to do so. I didn't mean to imply this was your view. Cheers Stephen=20 >=20 > Regards, Aaron Piotrowski >=20 >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20