Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112005 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 52077 invoked from network); 5 Oct 2020 11:26:29 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Oct 2020 11:26:29 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EBEB11804AA for ; Mon, 5 Oct 2020 03:39:36 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 5 Oct 2020 03:39:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1601894374; bh=yjwLgUoy43npWwraO+VF39S8ItkRgA5HYQEhfAi9gYc=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=CQFxLPlau8HprLcsEfvfYMIFOzrk3T85vh70QYvqYFCL9qbhM+KIEbC0DuU9FUsGd ma31yB767XNZDpBQleAPgxhnY+vEChM59J9jJW+7ftElnS5kINqN5M9e+bhURtmGI3 j5HIROCrkEpzkTxqF/T47x+Dbv/ymZ/yWeQhHkNo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.120] ([24.134.51.41]) by mail.gmx.com (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MKsj7-1k6tY31vUj-00LFZ1 for ; Mon, 05 Oct 2020 12:39:34 +0200 To: internals@lists.php.net References: <446c9894-191f-e53b-4534-31c4e7b91d7b@gmail.com> <881e2335-5f81-0d79-6a17-06bc20f14223@gmx.net> Message-ID: <873361ff-02c8-b9df-9b7a-c9e89e25a880@gmx.net> Date: Mon, 5 Oct 2020 12:39:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US X-Provags-ID: V03:K1:rmM+aBCuQryd+4Awmo7o+43LDMW0emkyYBJnnspfFJinkuppMHw Pq+NER2Z57NZxbf5Kcl1o3T8SbIO/mXo28l9OHSyk+3WGVCf5QBX9lIzpV2V4wNxL2FSvtr C/6vMaMZQIt2D5IyfBr35TUZddN4Yj9uC+M1CiBRz1+DoOpWcBL3ed2J0YODgI0lOw5jmOK gJ/piNZ7h/qq6hHDRGLgg== X-UI-Out-Filterresults: notjunk:1;V03:K0:XJ38Qa1g1BU=:sbkMF97H2CJh0dtbQ36oni NPQJpmIshbvsoGxGZVgM/CSsRIj28QoIWgXWQ7JxlCpZFPs55TFCR5b/H3H658WOMr148XzgH x74HEA6aAytdZlzVUJ9zuY8ZS21B6pSQQyChyGwAE1FoAQ6sf+ZJy6KNDhpv/+GqLtbgtu3gJ BLG+kxgb5GxlBV6pymrNHMAWj3J++fjBmd4yB8A9oC3CXZf9VgO/v/pX7KbVqjZbFIJr3IPmp FMosQ1I+OWpqNkx+ECEv/a2bKa0TzuamPp9REHi+8tCTGeE+4FvmvizPnPZW1pYmH7as41o9/ CJBALqWnumcsj+Tg2YpdSYBczDSuZtOEGKe2yyomekieiKxsHmrWk3odvFY2ln93H9/mk75Q1 GCEl4qq5h8rBZzVxCvHxqB6s9ap3JPOeRw72qoBDNPWfNmgKX5APn8QCVs9LlGhE/YnaowLs8 Q4s1USmOovPnd+Wsrho8N3hli+0Fs2bOW2UooloZUXOVOYRBIXrYSW//W2tqTA7M//1319nau hczWkEZ0OsjsewNCgDqnIf170jhGfxeV4h9KGlBMXHOXe6QO4J0mA3vN4UPosW3G0POW6PNF2 yNIpjUGJ9/jwtllhilDXvFh9aYoFFAJ7l4tmn0s1wLTE9rNUN7J1oQBYOGtPEKlECMdBIxN37 fO80Pgk+jCMdEGbZxPXVHh5WhzvUxc736L2rHwoF72Lh/mhAM/9ZXDi893eKvSRbTHbEvqX94 nvxMtkxd/2JtseQlBXZBQXs3auf2x9VoI7VFczFAXX2GlC2fD8pVJYYj6F4hP0W730c+d1jaB Kd+XjBAhcTxdbwervfuLm+1oX2cvQtaCD5uLPKFiWIwtXTI8KkgPGQOUAcLxRJc9WP0M46Oj/ Ibx9r7BAY6mBeDx7yiy5z4slJGhfyLuR3TntunZWFJCh2cunKZt9wKxmxFOILtNVsy2HVx67U jx+96o7gsUxk2c0z0PRBboPSRBZufYiN49XEs/tKrDKHg5DTRfWbF7u6/FxWws5ftAmy7qVQk lORGlYtFUgdTaO+JyBi6PTS2ssvTdyjm68A07UbizZylHqL1KyVC5QYUxa+bw5+0uSTvlEsrm LHnFm14wiwk+xtglga3j9HLejSjc9woS/UPTvU+XFSgePjhTzI9q7Rf0Zh2L2zPzzsOFdaYbd WOmFVaXorFICe/HijMoOxQ4KQJnH70IaaiJ1t41f1Y5JYElMrEDOd8dRX6FyWAvkbg0xp0iBl qWYEWDecIj1Pyiby0foyxZgcnRyL0u3B+Gkg2zA== Subject: Re: [PHP-DEV] RFC: Support for multi-line arrow functions From: a.leathley@gmx.net (Andreas Leathley) On 05.10.20 12:15, Deleu wrote: > To me that seems like a great argument in favour of the proposal. If you= 'll > want all variables to be imported (which in this case makes completely > sense), then `fn() {}` or `fn() =3D> {}` is much less verbose and inline= with > the mentality to reach for short closures. We reach for short closures t= o > avoid `use()` and convey that the outer process is intertwined with the > inner process. `fn()` allows to strengthen the concept that there's no r= eal > separation between running SQL stuff in a `callable` that wraps a databa= se > transaction. Not necessarily: the arrow functions were specifically implemented for very short anonymous functions with a return value. Making them more and more like the existing "function" syntax would lead to having two different ways of defining anonymous functions that mainly differentiate themselves by including the parent scope by default or not. I like the "function () use (*)" suggestion because it is explicit and opt-in. A shorter syntax like "fn () {}" is less clear, and it could lead to many people always using fn just because it is faster to write (and less to think about), which then could lead to unintended side effects because variables are being copied from the parent scope each time. When you see a usage of "fn () {}" while reading code you would not know if the person used it because it was faster to write, or if the parent scope variables are really needed.