Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123581 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 25A1A1A009C for ; Tue, 11 Jun 2024 14:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1718115559; bh=Me4PppGOeI9ifaNq2BNhtwAZC/5YK+c1zMcFHDSybzU=; h=In-Reply-To:References:Date:From:To:Subject:From; b=YoiJBe48ler8EAjPRRiGRsoncAkA5jJb41Ft8FwY1hKUR4mbFveGw1T0+g+qFO7zJ SH0idHCINbXMsKuXi6Gu7iC/KpfGlj9GYYF68PPqoxR5cf2ay0Chq7r6xtBfjkjbUO IpZ9UcRdesL98mryCt06ZkuLnHCdNOUs957SMst67EUC5yo17/AxKMh9dCvbHvKZH7 sbpq6hvtRjcT3/X5xj3fTvPOkOkg6ow/mFiA4KCgHfJNZfz2j6QbQoYC0C0uJB1gM/ qM+UhB+2fvyBu5ehHn03Pci62kXRgzz/nO2Sgh+3R5KOvMgUdvBfw4ed/BVM0RMAki LPC4EuDounpMw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 48EBE1809D5 for ; Tue, 11 Jun 2024 14:19:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fout1-smtp.messagingengine.com (fout1-smtp.messagingengine.com [103.168.172.144]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 11 Jun 2024 14:19:13 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id 9C89B13800F7 for ; Tue, 11 Jun 2024 10:18:05 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Tue, 11 Jun 2024 10:18:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm1; t=1718115485; x=1718201885; bh=r58vwSGzw9d3PxDd2n+9l Ov9nSD8qlUQ682QjMf/854=; b=Es6yq9xQ+hDl/clZzQD2QFD4vFgNH5tnX6KWn uYN7XHhp7eqWMaf53GwrcaFG+V90ImzspZ0iYHY7id5Lud4FR833o4fOEa6Gb5hA 1cD8FC7/5T1jMwvPXsDjmkWVqbRjZsgFs6ZRx8YLMjmBzNfRbfkPADOfrmsDNkWe ArWWofUJ4aDwYu9ZtZJYdpgAG3Tq0bW+pUEQJ++VVYNMNtkEG0hrz1moS8WqkmCo keS/dELtrfYEOt3Uxthd+XDIqvIKk6HVpj5amu3nvXWSg9YZ3YjIiGohYxx0RvGz 6Wqi4+1Qg0gp9TNc3UtpAVBcmJ+DXuOnHcoJkhV8wjpqmW86Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1718115485; x= 1718201885; bh=r58vwSGzw9d3PxDd2n+9lOv9nSD8qlUQ682QjMf/854=; b=P h35NrxOwl86xOt4bydpu1W8p+jELRFAu3hqe4mmmkfiUHsGw0Z8DI7NKGkEs3Bkd VAyjHWfY4e97pfAkO6+HzIyAPOj878FRTDxqIRwJLK9u585LMNPjU742PlKp6t4l AVxkBwM0Q3j2n8ezQFWwyRUbKmRtpjDpd/TFNWj51QlttoT5TQMbgWejlEOyV0zk AnHkoNAI6vlfUR/j2bu5zbExpLVzy/xXWduikJ2Jv2dZAQwhvz3ltobBsmP4jvCn hx5Tza/+QOnWTUcmsV7fVLgLEP2gvWwxj5uY92h55fHVn+wlYdoSFObt8bj2uZIG iYbQg9+o3PVc538gaY0Gw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfeduvddgjeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepffffffejffdugfegvedviedttedvgfejffefffej leefjeetveehgefhhfdvgfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id E33F11700093; Tue, 11 Jun 2024 10:18:04 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-515-g87b2bad5a-fm-20240604.001-g87b2bad5 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: In-Reply-To: <14f6e0a1-d01b-4dcd-a7d4-f8806ee1db19@app.fastmail.com> References: <0a6a61cd-f203-4dea-a7f8-97e6b885c52d@app.fastmail.com> <43606ecd-8838-476d-8fdf-acc6dbe26359@app.fastmail.com> <4d4df16b-af35-4245-85f4-016d66e8a4fa@app.fastmail.com> <14f6e0a1-d01b-4dcd-a7d4-f8806ee1db19@app.fastmail.com> Date: Tue, 11 Jun 2024 14:17:44 +0000 To: "php internals" Subject: Re: [PHP-DEV] [RFC] Asymmetric Visibility, v2 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Tue, Jun 11, 2024, at 1:48 PM, Rob Landers wrote: > On Tue, Jun 11, 2024, at 15:36, Larry Garfield wrote: >> On Tue, Jun 11, 2024, at 6:47 AM, Rob Landers wrote: >>=20 >> > I=E2=80=99m also not a fan of the prefix style, but for different r= easons. My=20 >> > main reason is that it increases the minimum line-length, potential= ly=20 >> > forcing you to chop things down into awkward looking lines: >> > >> > public >> > private(set) >> > string $longvarname { >> > get; >> > set; >> > } >> > >> > I find that extremely hard to scan, but maybe others do not. The mo= re=20 >> > natural looking syntax is easier to scan and reason about (IMHO): >> > >> > public >> > string $longvarname { >> > get; >> > private set; >> > } >> > >> > If I=E2=80=99m having to read the code, I prefer to have everything= near where=20 >> > it is used so I don=E2=80=99t have to scroll up to the top and see = its=20 >> > visibility. Granted, I haven=E2=80=99t used property hooks and I ha= ve no idea=20 >> > how IDEs will help here; maybe it is a non-issue =E2=80=94 but I gu= ess people=20 >> > still have to do code reviews which very rarely comes with IDE powe= rs. >> > >> > =E2=80=94 Rob >>=20 >> I have never in my life seen someone split the visibility to a separa= te line from the type and variable name in PHP. I don't know why anyone= would start now, especially not because of hooks or aviz. I just check= ed and PER-CS very directly states "All keywords MUST be on a single lin= e, and MUST be separated by a single space." So splitting it like shown= above would be against standard coding conventions anyway. >>=20 >> This is really a strawman argument. >>=20 >> --Larry Garfield >>=20 > > I=E2=80=99m willing to concede that it might be a straw man, though I = did not=20 > intend it as such. I was being serious in my pointing out of it=20 > increasing the minimum line length and PER isn=E2=80=99t the only codi= ng=20 > standard. It may result in some ugly code, as in my example. > > =E2=80=94 Rob I didn't think it was deliberate. But in practice: public string $foo; // 13 chars, excluding variable. public readonly string $foo; // 21 chars, excluding variable. private(set) string $foo; // 18 chars, excluding variable. protected(set) string $foo; // 19 chars, excluding variable. public private(set) string $foo // 24 chars, excluding variable. public protected(set) readonly string $foo; // 29 chars, excluding varia= ble. Even in the most pathologically long case, where you include every possi= ble modifier, we're up to 29 characters. Typical coding guidelines say = to use either 80 or 120 character lines. So even factoring in indentati= on, you're still going to need a 50+ character variable name before line= length becomes an issue. At that point, the issue is your silly variab= le name, not the modifiers. The far more common cases would be `private(set) string $foo` and `prote= cted(set) string $foo`, both of which are... shorter than `public readon= ly string $foo`, which we already have. In comparison, using hook-embedded style without hook implementations, w= e get: public string $foo { private set; } // 29 characters excluding variable So the base case with hook-embedded style is about 50% more characters t= han the prefix-style. The only way that it wouldn't be is to structure it like so: public string $foo { private set; } At which point I'd argue that's worse in every regard, especially with h= ow many properties are now defined in constructor promotion. That would= be vastly uglier in constructor promotion than the inline style, with e= ither syntax. To whatever extent we care about line length and conciseness, prefix-sty= le wins over hook-embedded, unquestionably. --Larry Garfield