Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98175 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61067 invoked from network); 4 Feb 2017 10:12:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2017 10:12:13 -0000 Authentication-Results: pb1.pair.com smtp.mail=ilija.tovilo@me.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ilija.tovilo@me.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain me.com designates 17.172.80.96 as permitted sender) X-PHP-List-Original-Sender: ilija.tovilo@me.com X-Host-Fingerprint: 17.172.80.96 st11p00im-asmtp002.me.com Received: from [17.172.80.96] ([17.172.80.96:43146] helo=st11p00im-asmtp002.me.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/A1-38491-CF8A5985 for ; Sat, 04 Feb 2017 05:12:12 -0500 Received: from process-dkim-sign-daemon.st11p00im-asmtp002.me.com by st11p00im-asmtp002.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) id <0OKU00F00H3TJG00@st11p00im-asmtp002.me.com> for internals@lists.php.net; Sat, 04 Feb 2017 10:12:09 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=4d515a; t=1486203129; bh=5S/12JNivijI/nJIaI/HKTGmjars1rB9NASwdR6waCk=; h=Date:From:To:Message-id:Subject:MIME-version:Content-type; b=FqLnfUv7+Qw8QJXSPwfcQxzwDMX59nGA82k7LPb0tadm3VkvNZdrnlplZd0EFwqFV 18X+aFqLK2R321HnI1zvrN4dUymMq4M57bzCWd2mG3fl1Jm+a3IxdSx8lGFdsfQnsf rVyHKf2kn/7/FU9sKZijby5RwuWZWRWUNc8DLkmro156TprUz+peHmXd62B7cwcn+u 7StgFQSmthXOhf06s24l0eFexY7aPN4WpgNRcz0JdlE8wX14lFeJ7B7LKvfWB7xmC6 Nv1xNbIv9gzhnBm9vthETzOruWd5e2d3VbMLcKVpZ96ynYXA7vFOaGat1WWEKGtF3g XiD0zY4N73tCw== Received: from icloud.com ([127.0.0.1]) by st11p00im-asmtp002.me.com (Oracle Communications Messaging Server 7.0.5.38.0 64bit (built Feb 26 2016)) with ESMTPSA id <0OKU00A3LHO7ZM00@st11p00im-asmtp002.me.com>; Sat, 04 Feb 2017 10:12:09 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-02-04_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1034 suspectscore=32 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1603290000 definitions=main-1702040113 Date: Sat, 04 Feb 2017 11:09:00 +0100 To: Stephen Reay Cc: internals Message-ID: <119a1b84-edff-424c-99ba-fd14cbc23ce4@Spark> In-reply-to: <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> <77287A6A-C3E9-4C93-A1F2-2899DAEA8738@koalephant.com> X-Readdle-Message-ID: 119a1b84-edff-424c-99ba-fd14cbc23ce4@Spark MIME-version: 1.0 Content-type: multipart/alternative; boundary=5895a8f5_327b23c6_4609 Subject: Re: [PHP-DEV] [RFC][Discuss] Arrow Functions From: ilija.tovilo@me.com --5895a8f5_327b23c6_4609 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi Stephen > Using type hints is a part of the language. It even has benefits that I= can absolutely see being used here: > > array=5Fmap(function(=46oo =24x) =3D> =24x->bar()); > > If =46oo is a class/interface with a method of bar, your IDE can know t= hat it's a valid method to call. > > That of course is in addition to the benefit of getting useful type err= ors from PHP itself. I agree but think that this is the wrong approach. PHP is a weakly typed = language. Doesn=E2=80=99t it seem wrong that you have to specify types in= more places than in many modern strongly typed languages=3F Look at Swif= t for example. IMHO, the right approach would be to implement proper clos= ure type hints. This has the benefit of letting the callee specify what k= ind of closure is expected (who knows that much better than the caller an= yway) while allowing for IDE autocompletion. Nonetheless, specifying type hints on the closures is what we do right no= w. The approach Levi suggested works well with that. > So we should instead use syntax already used for bit wise OR, and furth= er confuse the situation when the function has no parameters and reusing = the logical OR operator. Brilliant. > > This is still a function, it has slightly different semantics, just lik= e how a regular function, a class instance method and a static class meth= od have slightly different semantics: we still use the function keyword f= or all of those. > > The static keyword is used for functions, class static properties, stat= ic variables and even static closures: it's semantics are slightly differ= ent for each case but we reuse the same keyword. As Levi already mentioned, this argument is similar to claiming reusing t= he =60function=60 keyword could be confusing. Both should be perfectly cl= ear to anyone who is serious about programming. I think we can expect for= programmers to get informed about new features before using them. This s= eems to work for any other language. Also, it=E2=80=99s not like the sugg= ested syntax is something we=E2=80=99ve never seen before. Ruby has it, R= ust has it (or something similar at least). The rest personal preference = I suppose. I can see how people like =60function=60 more because of consistency. I l= ike =60=7C=7C =3D> expr=60 more because of readability (for me, the less = reading the better :P). =40Levi Maybe it would be best to vote for the closure syntax=3F My least= favourite option is better than the R=46C getting shot down because peop= le dislike the syntax. --5895a8f5_327b23c6_4609--