Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98145 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86548 invoked from network); 3 Feb 2017 20:37:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2017 20:37:28 -0000 Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.162 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.162 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.162] ([81.169.146.162:33725] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8C/E6-38491-60AE4985 for ; Fri, 03 Feb 2017 15:37:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1486154244; l=8301; s=domk; d=kelunik.com; h=Content-Type:Cc:To:Subject:Date:From:References:In-Reply-To: MIME-Version; bh=LPEFQv5yiYiJEkJ4WHyX6PppA3Qi6SZF1mU2qmC8NmA=; b=Axwosjg1gX+EJ5AHgb1o4DQyNOBf5ovVJ349dTmlnqjOLfzwV37ap+olTV6jCa/rcI aJ5M21cc6lnhc097ClOfWg4b+uVbCwhjXqCLGG12m9tOrUmo0AO+4YLa0AzSk/GQ+t0p 1YWamMdxyY7NJPykAK1WUF76VA15lDeyke3QI= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLDup6E67mzuoNJBqD/sAU= X-RZG-CLASS-ID: mo00 Received: from mail-qt0-f170.google.com ([209.85.216.170]) by smtp.strato.de (RZmta 39.11 AUTH) with ESMTPSA id V0a8bat13KbOzb8 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp384r1 with 384 ECDH bits, eq. 7680 bits RSA)) (Client did not present a certificate) for ; Fri, 3 Feb 2017 21:37:24 +0100 (CET) Received: by mail-qt0-f170.google.com with SMTP id w20so48440567qtb.1 for ; Fri, 03 Feb 2017 12:37:23 -0800 (PST) X-Gm-Message-State: AIkVDXL/w8CDnojVn1nay9KvNeaLcKd78lwBxsbVYtPX9Po3dQ3QqJznT5WC3OqYUZHFFA9vmIAImyHVUzf7mg== X-Received: by 10.233.237.136 with SMTP id c130mr16156961qkg.160.1486154241895; Fri, 03 Feb 2017 12:37:21 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.144.132 with HTTP; Fri, 3 Feb 2017 12:37:21 -0800 (PST) In-Reply-To: References: <19.45.38491.677D4985@pb1.pair.com> Date: Fri, 3 Feb 2017 21:37:21 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Levi Morrison Cc: Andrea Faulds , internals Content-Type: multipart/alternative; boundary=94eb2c09830eab88a00547a63fb4 Subject: Re: [PHP-DEV] Re: [RFC][Discuss] Arrow Functions From: me@kelunik.com (Niklas Keller) --94eb2c09830eab88a00547a63fb4 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2017-02-03 21:23 GMT+01:00 Levi Morrison : > On Fri, Feb 3, 2017 at 12:18 PM, Andrea Faulds wrote: > > Hi David, > > > > David Rodrigues wrote: > >> > >> Hello folks! > >> I just not understand why "function" should be abbreviated. It's about > >> "how > >> less character better"? I don't see it too much on PHP. I guess that i= s > >> more simple keep what exists current "function", that all knows about > >> (that > >> should be better than the next example): > >> > >> $mapped =3D array_map(function($x) =3D> $x + $y); // vs current: > >> $mapped =3D array_map(function($x) use($y) { return $x + $y }); > > > > > > I feel the same way. It would be nice to have shorter syntax, but it > > sacrifices readability and familiarity here, and adds yet another new > > keyword. > > > > It also feels inconsistent=E2=80=A6 isn't "fn" just short for "function= "? Why is > it > > exclusive to the =3D> syntax? > > This is not exactly on topic... unless you are implying you'd prefer > the `|$x| =3D> $x + $y`? Maybe you missed [this][1] message? > Why is using "function" instead of "fn" not on topic? Thanks to everyone who has participated in the discussion thus far. > Primarily the feedback has been directed at the `fn` keyword. Let me > provide two benefits and drawbacks of using `fn` as a keyword: > 1. `fn` is searchable in search engines and in our manual > Just as "php function" is, too: http://php.net/manual/en/language.functions.php > 2. Is more intuitive than just syntax > As is "function", too. With the added benefit that people are already familiar with it. > However, `fn` does have downsides: > 1. Can break existing code > Which doesn't happen with reusing "function". > 2. We already have a similar keyword `function` > Right, so why not use that? > To that end, I'd like to gauge interest in a pure syntax based > alternative that is similar to Rust and Ruby. > Instead of: > fn(params) =3D> expr > What about: > |params| =3D> expr > This trades the advantages of the keyword for the advantages of pure > syntax, and happens to be two characters shorter. To be explicit: > 1. Preserves 100% backwards compatibility > 2. Avoids having two keywords that both mean "function" > 3. Is not easily searchable in engines or in the manual > 4. Is a tad bit shorter > 1, 2, and 3 are also solved by using "function". 4 is counting characters instead of focusing on readability. There are more drawbacks to that syntax like no parameters looking pretty weird: || =3D> Regards, Niklas > [1]: http://news.php.net/php.internals/98136 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --94eb2c09830eab88a00547a63fb4--