Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114345 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 15766 invoked from network); 10 May 2021 16:50:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 May 2021 16:50:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9397D1804E3 for ; Mon, 10 May 2021 09:58:28 -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 out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (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, 10 May 2021 09:58:27 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 5E8085C01B7 for ; Mon, 10 May 2021 12:58:27 -0400 (EDT) Received: from imap8 ([10.202.2.58]) by compute4.internal (MEProxy); Mon, 10 May 2021 12:58:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding: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=fm2; bh=pdYLNT6Jx8LV0knr8WWT2w4RsUonmSVdNjqXp1etF 8k=; b=NE/z0G6xvwUiExpnHR8crlPg1B0OiFeuTrmVc1+XEXgNBv7VFw7UrKAYa 03jSBwsQgXprh+zGuy0+mBMIjukW0OsDWLjaunEJYHMolyuv/6NIfPIq6I4mANxN A3raWadOIMIXQLeipc9fmLVfE0redtv7qLal/JIyoSx8N+AqIpvvmEF20W8zlE1E Ep9JVTfafUUUShKMFNl2Ii7K40k+tt6AT+RDo0SHf4PkWbBha8VLbMXYOX8uxDhJ yMUCQysmNT//qhC351echjYeKCDUxaHi17gzj4P/w8R18kW7TlBLrLULxmfeeeXW 3qN9eo/qIdmWDfsckVI3/KJzd+zjw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdegkedguddtjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepfdfn rghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrd gtohhmqeenucggtffrrghtthgvrhhnpeffffffjeffudfggeevvdeitdetvdfgjefffeff jeelfeejteevheeghffhvdfgleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 1761F3A04D9; Mon, 10 May 2021 12:58:27 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-448-gae190416c7-fm-20210505.004-gae190416 Mime-Version: 1.0 Message-ID: <973730f8-1c9c-4208-b1fa-5f1048f6d6cf@www.fastmail.com> In-Reply-To: References: <1620635361.9147.0@gmail.com> Date: Mon, 10 May 2021 11:58:01 -0500 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC][Draft] Body-less __construct From: larry@garfieldtech.com ("Larry Garfield") On Mon, May 10, 2021, at 9:40 AM, Chase Peeler wrote: > On Mon, May 10, 2021 at 6:31 AM Guilliam Xavier > wrote: >=20 > > On Mon, May 10, 2021 at 10:29 AM Mat=C4=ABss Treinis > > wrote: > > > > > Hi everyone, > > > > > > Since constructor property promotion is now implemented, and it lo= oks > > > like it could become a widely used feature, I am proposing a small= , > > > cosmetic change in syntax for constructors in concrete classes to = do > > > away with empty constructor body. > > > > > > Here's an example of how this would work: > > > > > > > > namespace App; > > > > > > class Foo { > > > public function __construct( > > > private Bar $bar, > > > private Baz $baz > > > ); > > > } > > > > > > Some notes to this: > > > > > > - Since this is similar to already existing syntax for body-less > > > methods, parser should not be affected that much. I hope. I really= have > > > no idea. > > > - Syntax would be optional - meaning, you can as well continue usi= ng > > > empty body, just that in this case the body would be implied empty= . > > > > > > Thoughts? > > > Regards, > > > - Mat=C4=ABss > > > > > > > > Hi, > > > > To me `;` means not "empty body" (that's `{}`) but really "no defini= tion, > > only declaration" (or "no body, only signature", and also "no code > > executed"), i.e. an *abstract* method (either explicitly declared so= in a > > class, or implicitly in an interface). > > > > Granted, property promotion is already special (cannot be used in an= > > abstract constructor), but it can also be mixed with non-promoted > > parameters and body, so I feat that your proposed alternative syntax= would > > bring more confusion than convenience :s > > > > Regards, > > > > -- > > Guilliam Xavier > > >=20 > I'm ambivalent about this proposal, but figured I'd throw out one adva= ntage > to ; over {}. In my opinion, ending with a semicolon is a very clear w= ay of > saying there is no body to the method, while having {} could indicate = that > implementation of the body was intended but never actually done. I kno= w > that when I'm writing new classes I often will set up the method signa= ture > but leave the method body empty while I finish the code that utilizes = that > method. I don't know if that is justification for the proposal, but it= is > one reason why ; might be preferred over {}. >=20 >=20 > --=20 > Chase Peeler > chasepeeler@gmail.com I agree that in the grand scheme of things this would be a minor matter,= but aesthetically I would prefer it as well. The {} annoys me, CS tool= s or no. Related: I feel the same way about empty-classes and interfaces, which i= s often the case for exceptions where all you're doing is declaring a ty= pe. I figure that would get even more pushback, though. :-) As a data point, you can already do the same "semi-colon for no body" fo= r foreach, for, and while loops. I've only ever done it on foreach to r= unout an iterator, but it works on all three today. --Larry Garfield