Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113829 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 25921 invoked from network); 28 Mar 2021 12:38:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 Mar 2021 12:38:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4F0FB1804C0 for ; Sun, 28 Mar 2021 05:35:35 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,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 mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) (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 ; Sun, 28 Mar 2021 05:35:34 -0700 (PDT) Received: by mail-io1-f50.google.com with SMTP id j26so9966496iog.13 for ; Sun, 28 Mar 2021 05:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ydR9b1BM3/3BM3TsYAuNjE+Z3zr9+EkQ9/I2lCDhJ4g=; b=OXk+fuWJJqt7pjTFDSWmX1aJMYbGzH8iO0m312KVR96ZWBxIRDK/pUNFE1d9MUQT5O uWzaifOVYfrtrwp8+luURwwcdmpqi+BhJ9jsF8uQqr5yhVBqky9QcnoIRLQyy/XN9xnQ rSDFUEREz8EawGT/+zxhTUt7dp4/jhdsqZ+TD18apjKqYaep7rMxsIn52O0aenryI/L+ TJ5H4vmLPHCazkyR8I3ROGSDcAZ1CN/L9OtzXqR/EhFL+s4hpqs/m9Ps/4ScJd64xHaG eAysxPWt+6KjqNI+Mwtpfkq87jHmBSwLtDX2kzny2S9bB5r4iw2dTib0oWhTWr9RfoyO FSlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ydR9b1BM3/3BM3TsYAuNjE+Z3zr9+EkQ9/I2lCDhJ4g=; b=VvPhpzhaB6mABKSjhQws2K6qWybnN/U8bNH3a5zMy1sY/QzzOjBBR6pqqMNJF0DTE+ bkg1oZ4f4grSOZVzkVZQ/Rz6lS0MqZAHg3aYPwkkpzZVILyefUc3g+BTP7kTLe/u10jw ICHK2k6aoiNbr3rpacB8UbuMtI7CT5xNlgrNN1qUi5zq5lRL3XvAh/m6KJhIFN6hcaaz L1GPmRS7qwK3hH2txd189+IDNWZkfUOyK1N+wOFJj0AVfwqKcdz7DGRGUylhgtoDUG4T tc6OwrU3OAniPUGSBjS5l7pSmeUtU29ywQ8EORfJPpyYE8hhD5OTmKmqvbtABaJQJ42v P3+A== X-Gm-Message-State: AOAM532kgLWkXfVpLjPMqoXr5o62JizKXtE/YqHLitjuu7ai4pxegpFr VHyfL1dfq3ZeOEbbh+M4rqsUYeLQE3qK0Gd683M= X-Google-Smtp-Source: ABdhPJw4BBTtL+b4LMaFUOg2Clp1kzrPOKxy4a+naf09BYpWhOAgYr1RE23Jc6VO9XxKAx7mSMdp9c3G02zC7f00lFA= X-Received: by 2002:a05:6602:1207:: with SMTP id y7mr16645211iot.23.1616934934279; Sun, 28 Mar 2021 05:35:34 -0700 (PDT) MIME-Version: 1.0 References: <88c9eb5f-f80c-4869-b7f8-1b58b9e2eaa3@www.fastmail.com> <605bae82.1c69fb81.f49f7.d11eSMTPIN_ADDED_MISSING@mx.google.com> <919e30e7-3e5e-d955-7bb4-1e1b5825cdd1@gmail.com> <635DD146-FC6F-4991-8D2C-5A6B492722D5@newclarity.net> <734f12de-da98-6b76-c2fe-8682f4d177aa@gmail.com> <36E45DD6-E2BD-4801-BAAE-4355C83D1AC3@newclarity.net> <15AE4315-A456-4ED8-990A-49EBD76C5B46@newclarity.net> <5501FE70-FBED-47EB-8010-173644BC064F@newclarity.net> <3d453ce7-db16-fb75-91b4-9a2a71994164@gmail.com> In-Reply-To: Date: Sun, 28 Mar 2021 14:34:59 +0200 Message-ID: To: Kalle Sommer Nielsen Cc: Rowan Tommins , PHP Internals Content-Type: multipart/alternative; boundary="00000000000061f8b605be9800e4" Subject: Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and shortfunctions take 2 From: deleugyn@gmail.com (Deleu) --00000000000061f8b605be9800e4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > > but then we can bring up the side running RFC from > Larry which proposes to make the same short syntax available for other > function declarations, how would this work then with this mindset of > `fn` meaning auto capture? Does that mean a procedural function > declared with `fn` will now inherit the scope from which it was > declared (usually the global scope)? What about methods declarations, > do they import properties into the local scope? How does traits > interact here, same as methods? > I think I remember the 1st version of Larry's RFC proposing `public fn classMethod(): bool =3D> $this->myAttr;` as a class method which seems to match what you're trying to say here, but that has been withdrawn and the RFC no longer proposes the fn keyword for class methods or function declarations, which is discussed under *Background* of RFC https://wiki.php.net/rfc/auto-capture-closure. Larry and Nuno may correct me if I'm wrong but as far as I understood, that change happened to address exactly the points you're describing here: what does `public fn classMethod(): bool` would capture? There's actually little to no reason to do it. Larry's RFC still proposes a great improvement for getters/setters/short methods and Nuno's RFC allows us to write code that is naturally expected to work, such as `fn () =3D> {...}`. As for making `fn` an alias of `function` I believe that is already broken because of 7.4 arrow functions. As you describe, that would be "an exception" to PHP syntax, but more pressing it means that we would be wasting the potential of 2 separate keywords having different goals. I think it was Nikita that once said that we have a very limited budget on what we can do/offer through programming syntax and throwing `fn` out would be such a waste of that limited budget. --=20 Marco Aur=C3=A9lio Deleu --00000000000061f8b605be9800e4--