Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123174 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 9A2101A009C for ; Tue, 23 Apr 2024 09:07:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1713863278; bh=C9mZRdA6UHh8G3+OrdotdhbkYrWgp2UPFNYIrE8/gQk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=h7ETOeENqgAiGoV50ty25UxboDdRzb06OGIuqtnZvDlhkmTdQFVsWxO4cnCI4+nJq vOj4aSSK+QHFBPxcZiQSd4vIKiH8iFJcIxeLXW4bhwUChh8afmz+U0WjmmrKtF0jVX 3i+FdRE3rJtaQ4NFhrE8mEV5Mz3waZJbH639nPfMx6Vqwcm5efNtviujjVXdQlrX3M Kuv+VPH+Puw6606wYhBEwUgXR4AJQKm2O7jy2hp5OAy5IcoopO+tC+Wbo9Z6R7IIC6 Jejth9xh2il+3bDsRvEpgGMf1gZq4oSXzmaYplhJToTGz/goeTKRIDl08PdmvSk/S2 f7SGzy7IOt7Bg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 56BE6180BAF for ; Tue, 23 Apr 2024 09:07:55 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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, 23 Apr 2024 09:07:54 +0000 (UTC) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4187c47405aso36327025e9.3 for ; Tue, 23 Apr 2024 02:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713863234; x=1714468034; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=DhXMzQilJF5yBHwGapFxdBYos0EsdBlQaK3JlEKxX5g=; b=GOVHY2aYIz2nPyr8XRK0+gp4KOGAHWGgHynKBG42b3evVQnI6wHkAe2isTs+cCD4Wz HNS0K4rytrlJGxyCuaIGM7D09TEfoC1ZcP1bOKM5oGupEZqhWuaNeTmmqNsqN0RD6vKZ SjqQsHpjjEIucybUjLoJfVsHA3yj+erloXRGOEWGILhiIp2ZZ9ejL5m4acLvbcKxeNCt kSsduuoey8C13WKj1+nImRksUd+XQXFrN/d9+bhvdQQFN9UrXx8G8JbcFDoJ+l5NnLCt N3WO5Z6ctchKP4jPwZRR8/qECzDpyePAFFgosxW5FtO8Gd2L7b+g5nvR9GfUevm0vVtp kb8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713863234; x=1714468034; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DhXMzQilJF5yBHwGapFxdBYos0EsdBlQaK3JlEKxX5g=; b=TwLlvBNONVo5gQsB3sJzK5c/u02S7Jc1/H10ryw4H+7YBR14j9kAb2oKRFfF86FS/L wCEUeyhIiSFq9gKHwbLD0xXLcPYT7ETd1v1KtJDwDNufKoQ/sTsmzJTQg8/A2RO+tJVI qnz1k8ZQcvZsJkMD0W0UAd3kGkl77GvxWokjIJ0K81uaKNNBoFes5j9lKgE24qdfWT50 NuR534A8kEXbtGN0P4Xg+vHXpVjyearesxocTPYipFE99mA98JbIia9uzZbM6YoPA3yZ O/x9n1ettdMtsvkuCxrVYXL0pA7ZxiFJHfZRKXH1Ca995CgK6Q7HNsBOhLo49LgRzNyE 80sA== X-Gm-Message-State: AOJu0Yy2leKRdQ4Yn46Km6UIwevwS+hjY6RQfraWGbjgxBy2xLHETeiJ RjztRDgwWC9BUFu6AwaM/1Fyi1EYygjockJ78NacScEj+dm6GrSj4aX/MT7DzZPSCqEMVFwSnnx UmmR6KGXNRWBevwJN6cy03OVUpb9Nvt85Lg== X-Google-Smtp-Source: AGHT+IFkhPw3XF5MFtERVtLJ2hleBBL6P65+CcxslYKPBGnhaKc/wJJ/AhzC+whLEBqpEet8SHNNykzluDhWtBjLujY= X-Received: by 2002:a05:600c:1c84:b0:418:e88b:92c3 with SMTP id k4-20020a05600c1c8400b00418e88b92c3mr7825419wms.2.1713863233327; Tue, 23 Apr 2024 02:07:13 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <0466054f-bbec-47fd-8452-e848ebec7ec9@app.fastmail.com> In-Reply-To: <0466054f-bbec-47fd-8452-e848ebec7ec9@app.fastmail.com> Date: Tue, 23 Apr 2024 12:07:02 +0300 Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] new MyClass()->method() without parentheses To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000003762c20616bfe1ca" From: udaltsov.valentin@gmail.com (Valentin Udaltsov) --0000000000003762c20616bfe1ca Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable =D0=B2=D1=82, 9 =D0=B0=D0=BF=D1=80. 2024=E2=80=AF=D0=B3. =D0=B2 19:41, Larr= y Garfield : > On Mon, Apr 8, 2024, at 6:08 AM, Valentin Udaltsov wrote: > > Hello internals, > > > > > > > > I would like to propose a syntax change for PHP 8.4 that allows to > > immediately access instantiated objects without wrapping the expression > > into parentheses. > > > > > > > > This was requested and discussed several times, see: > > > > - https://externals.io/message/66197 > > > > - https://bugs.php.net/bug.php?id=3D70549 > > > > - https://externals.io/message/101811 > > > > - https://externals.io/message/113953 > > > > > > > > Here's what you will be able to write after this change: > > > > ```php > > > > class MyClass > > > > { > > > > const CONSTANT =3D 'constant'; > > > > public static $staticProperty =3D 'staticProperty'; > > > > public static function staticMethod(): string { return > 'staticMethod'; } > > > > public $property =3D 'property'; > > > > public function method(): string { return 'method'; } > > > > public function __invoke(): string { return '__invoke'; } > > > > } > > > > > > > > var_dump( > > > > new MyClass()::CONSTANT, // string(8) "constant" > > > > new MyClass()::$staticProperty, // string(14) "staticProperty" > > > > new MyClass()::staticMethod(), // string(12) "staticMethod" > > > > new MyClass()->property, // string(8) "property" > > > > new MyClass()->method(), // string(6) "method" > > > > new MyClass()(), // string(8) "__invoke" > > > > ); > > > > ``` > > > > > > > > For more details see the RFC: > https://wiki.php.net/rfc/new_without_parentheses > > > > Implementation: https://github.com/php/php-src/pull/13029 > > I always thought there was some technical parser reason why this wasn't > possible. Maybe that was true in 5.x but isn't anymore? > > I cannot speak to the implementation, but I'm all for the change itself. > > --Larry Garfield > Does anyone have additional feedback? I'd like to start voting on Thursday, April 25th. I've also added a section on other syntax ideas that have been expressed on Twitter and in the PR: https://wiki.php.net/rfc/new_without_parentheses#other_syntax_ideas --=20 Valentin --0000000000003762c20616bfe1ca Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

=D0=B2=D1=82, 9 =D0=B0=D0=BF=D1=80. 2024=E2=80=AF=D0=B3. =D0=B2 19:41= , Larry Garfield <larry@garfie= ldtech.com>:

On Mon, Apr 8, 2024, at 6:08 AM, = Valentin Udaltsov wrote:
> Hello internals,
>
>
>
> I would like to propose a syntax change for PHP 8.4 that allows to > immediately access instantiated objects without wrapping the expressio= n
> into parentheses.
>
>
>
> This was requested and discussed several times, see:
>
> - https://externals.io/message/66197
>
> - https://bugs.php.net/bug.php?id=3D70549
>
> - https://externals.io/message/101811
>
> - https://externals.io/message/113953
>
>
>
> Here's what you will be able to write after this change:
>
> ```php
>
> class MyClass
>
> {
>
>=C2=A0 =C2=A0 =C2=A0const CONSTANT =3D 'constant';
>
>=C2=A0 =C2=A0 =C2=A0public static $staticProperty =3D 'staticProper= ty';
>
>=C2=A0 =C2=A0 =C2=A0public static function staticMethod(): string { ret= urn 'staticMethod'; }
>
>=C2=A0 =C2=A0 =C2=A0public $property =3D 'property';
>
>=C2=A0 =C2=A0 =C2=A0public function method(): string { return 'meth= od'; }
>
>=C2=A0 =C2=A0 =C2=A0public function __invoke(): string { return '__= invoke'; }
>
> }
>
>
>
> var_dump(
>
>=C2=A0 =C2=A0 =C2=A0new MyClass()::CONSTANT,=C2=A0 =C2=A0 =C2=A0 =C2=A0= // string(8)=C2=A0 "constant"
>
>=C2=A0 =C2=A0 =C2=A0new MyClass()::$staticProperty, // string(14) "= ;staticProperty"
>
>=C2=A0 =C2=A0 =C2=A0new MyClass()::staticMethod(),=C2=A0 // string(12) = "staticMethod"
>
>=C2=A0 =C2=A0 =C2=A0new MyClass()->property,=C2=A0 =C2=A0 =C2=A0 =C2= =A0 // string(8)=C2=A0 "property"
>
>=C2=A0 =C2=A0 =C2=A0new MyClass()->method(),=C2=A0 =C2=A0 =C2=A0 =C2= =A0 // string(6)=C2=A0 "method"
>
>=C2=A0 =C2=A0 =C2=A0new MyClass()(),=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 // string(8)=C2=A0 "__invoke"
>
> );
>
> ```
>
>
>
> For more details see the RFC: https://wiki.php.= net/rfc/new_without_parentheses
>
> Implementation: https://github.com/php/php-src/pull/13= 029

I always thought there was some technical parser reason why this wasn't= possible.=C2=A0 Maybe that was true in 5.x but isn't anymore?

I cannot speak to the implementation, but I'm all for the change itself= .

--Larry Garfield

Does anyone have additional feedbac= k? I'd like to start voting on Thursday, April 25th.
I've= also added a section on other syntax ideas that have been expressed on Twi= tter and in the PR:=C2=A0https://wiki.php.net/rfc/new_without_parenthe= ses#other_syntax_ideas
= --
V= alentin
--0000000000003762c20616bfe1ca--