Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112089 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 36450 invoked from network); 21 Oct 2020 13:33:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Oct 2020 13:33:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7C8821801FD for ; Wed, 21 Oct 2020 05:50:37 -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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 21 Oct 2020 05:50:36 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id DF0A9930 for ; Wed, 21 Oct 2020 08:50:34 -0400 (EDT) Received: from imap26 ([10.202.2.76]) by compute4.internal (MEProxy); Wed, 21 Oct 2020 08:50:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=lV6ij1 ZN97+3BSyyVe9taNe8GtTigQ7VoHDuNiVlX78=; b=d5hcfsyjIFk/cfp1YQln7C JwyCu0uHZCKvw1cCWW+DJb81/UgsM0hSDm2gy8tgoA0+vNWZRMg68ZsZr7uYdNfK 7nWQW3jV0WaHgbwCsVSQ+wgIsBWknYQ1jyxcRBTpAr0KEiltKzp3pHHQUkpM/NbP v0m9pKRg9sgNaJ9WxP1fbjWj+VZC2rMkLLCL/R7qioSYRI2mpUY00tm61BM186X3 b8XqrvgS9Om7xKdA/MzP+hZgOTDEdW8dli7ryRjlTnbJ3AEeO59/PYdJNzRsRYnB KNGMZf4RP6sW9CcInZUf69MA+vBjA0so3RlR5+q7MsfiwTL9d/6wndFwt6qao6PA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrjeehgdehjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuggftrfgrthhtvghrnhepveehhedvveejledvvefgleevffdtjeekledvkeegheff gfeivdejhffhledtudetnecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgv lhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 2F00F14200A2; Wed, 21 Oct 2020 08:50:34 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-502-gfef6c88-fm-20201019.001-gfef6c888 Mime-Version: 1.0 Message-ID: <11124061-cfeb-4668-8a8d-a11aa683477a@www.fastmail.com> In-Reply-To: <41AA7084-18F3-431B-B135-46C44FC26D1E@newclarity.net> References: <41AA7084-18F3-431B-B135-46C44FC26D1E@newclarity.net> Date: Wed, 21 Oct 2020 07:50:12 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Short-function syntax From: larry@garfieldtech.com ("Larry Garfield") On Tue, Oct 20, 2020, at 11:08 PM, Mike Schinkel wrote: > > On Oct 20, 2020, at 2:19 PM, Larry Garfield wrote: > > > > A while back, Nikita mentioned that it should now be easy to offer an abbreviated syntax for functions that are just a single expression. I decided to take a crack at it and it turns out he was right. I thus offer this RFC: > > > > https://wiki.php.net/rfc/short-functions > > > > Hopefully I made a decent enough case for it. It's entirely a convenience factor, but I think for many OOP cases (getter methods and factored out operations) and functional cases (where functions should generally be a single expression conceptually) it does make the code nicer, more compact, and more readable. > > Simple and elegant. I like it. > > I have two comments, but not about the feature. > > One comment is about the RFC itself, and the other is about a use-case > used to justify the feature that could warrant its own bespoke feature. > > > 1. The section on "Conditional methods" is really just an argument > about the benefits of encapsulating complex logic into well-named > functions as you could achieve exactly the same benefit with the > existing function syntax. It does not appear to me that it provides > any specific justification for the feature in the RFC. Should it really > be part of the RFC? In pre-RFC discussion, one of the pushbacks I got was "pfft, how common are single-line methods anyway?" That example is mainly to demonstrate "quite common, actually, in fact common refactoring patterns tend to produce them a lot." It's not the refactoring itself that benefits, per se, as it is the refactoring technique produces functions that would benefit from it. > 2. In the section "Decorating functions in live code" where you state > "Often times, methods exist that are just delegating to some other > method, either in the same object or a composed object." I think we > could see great benefit from explicitly building delegation into > classes much like how Go provides type embedding[1]. For PHP, extending > the syntax for traits could be used to support delegation of one class > to another embedded class. Can you see this as a potential feature? > > -Mike I'd be in favor of some kind of automated "delegate this interface's methods to this object property" syntax, although that is unrelated to the RFC at hand. --Larry Garfield