Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123180 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 70A0A1A009C for ; Tue, 23 Apr 2024 12:51:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1713876757; bh=l4aqHfv8uNHqDo/G2xm8IyJVhWHqCYHqaeiwGGyDP0g=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=nXecP3mt3nQCza9VkUZZltsEK16sXNqEMD7zAg2mNkudqtzn+E0GDyxcXtnqAuzvy r4aa2/hmJxYxE4HkRywYeUWrIMilRJbkn6EAsodL59u05KsoPepofLFuVMTPTG4qZ1 +EzZEaUjvxxmBCiTeu/4V3QOCGUKPRWfqXmUBYVJWBzmxAbfGG7YcvUYwuQdYQM/ib tA3SRpJcl6XK1cETLhT4klDGViOC7z1+fXOYhRdSsihG4KVk7tnVrH4nkJ6ewrAMIk apqSzls4lpHprlGXtHfiiZR0CELwfGy/eHoVhwH4hjBpVo/62XZFCE+H0R42gLrcb8 g55CrDYmDN6Hg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 61F1318006D for ; Tue, 23 Apr 2024 12:52:35 +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.2 required=5.0 tests=BAYES_40,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-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 12:52:34 +0000 (UTC) Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a52223e004dso537530266b.2 for ; Tue, 23 Apr 2024 05:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713876714; x=1714481514; 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=cjAKYc5DMKmZ17DSWQnLLxkNOk1WAx/QyeJ4nmmVd/E=; b=ZXhnLwrlRAjgDCiu4StUymwEHYJZZ+E8un37yPmBN+jDg1nYdbp8s9QQ44zTrO7U4i 9ftk2ybM2i8ibCJ7+LwelE37x1R9moM7EvbZyhQsREJI29sjCxpxhQr/CdVD3vhYLDOC +M2Wwa+1UCx3UnCmu2W5/1a9O4n1vuUuJMX808LPOJuzRn2SsGPgucBRspxaIHsiOF8/ Rl8SZYKXdTjn3SIxfZR/Llbx/5x1V8nIoMJE1y/WsaQmiiK2sNnDbOT5sZhVNT4/cOjx Vyw8aT2nVie7sL07KZrxqn7sUrYLoQBYDJ0bJowH6kDGcgnjCBBvWWCsW8d27jXD2jF9 PPyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713876714; x=1714481514; 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=cjAKYc5DMKmZ17DSWQnLLxkNOk1WAx/QyeJ4nmmVd/E=; b=j1SQZFxDiy9TAAlHNBpuVxDQssW12Vj2t0ZTnwMk3/b5p3WSGo6bLkNStdyPU6biT8 TBg/PeEYGThbt96j91Bl59YeLf5KhaZ70KhaX86ux4Wb6K80K9sT+2lJKwAoj/v9r9Am W6rQ2qb6WvSdqNYo9MHsM6QJG5d9YXD3dgTlWVsKg+VtdzijcsSDur9rldjZW6fnsJfx j9SN9bXbHVNJtIZyvoUhog/WrVy3M01C0fEjIEUpPkbzEcnD7Cr6KsC47DD3V6TbBuyZ 4MSkR4jBVjJ2ywtJ0z5DyjYv/ySwPM5LxM5zRXRcZ652fHyrGccCmHyAfoWIF25L8wIL Asqw== X-Forwarded-Encrypted: i=1; AJvYcCWu1/ufoyKhiZS04nU4qpffwpREfIF74VvfSDKYubk3Sh3yiAHq1lNDYxCoioosIdt5OvykAXLcJB7YZRaVJKA2R3PQ+OjiYg== X-Gm-Message-State: AOJu0Yyds7D9T2uQJiCxCJGN7r1Q8ZIPDQxhCGiFUcUINfGonwAtNnvL Q4WVLElUXSTS1WmX6n3JnKkiU3Tdz8YqRHlJWpWkAMSDOcCexuPNnf94Kek4fINgHi3vcmF2L9q YSsqTy9eaY0QFPG7CGBQeiOcr8nPlanQE X-Google-Smtp-Source: AGHT+IGKrbOz0jVx9h6oPdJN/qTgzsSg3RI/8dI3xl8+LB51xkTmnQjov50aMFYyUatkbxV/1QCeCks3RskDKv2jBU4= X-Received: by 2002:a17:907:7284:b0:a55:b488:27b9 with SMTP id dt4-20020a170907728400b00a55b48827b9mr6721469ejc.38.1713876713384; Tue, 23 Apr 2024 05:51:53 -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: Date: Tue, 23 Apr 2024 14:51:26 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] new MyClass()->method() without parentheses To: Robert Landers Cc: Valentin Udaltsov , Larry Garfield , php internals Content-Type: multipart/alternative; boundary="000000000000b0b2790616c304da" From: kjarli@gmail.com (Lynn) --000000000000b0b2790616c304da Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 23, 2024 at 1:20=E2=80=AFPM Robert Landers wrote: > On Tue, Apr 23, 2024 at 11:10=E2=80=AFAM Valentin Udaltsov > wrote: > > > > =D0=B2=D1=82, 9 =D0=B0=D0=BF=D1=80. 2024=E2=80=AF=D0=B3. =D0=B2 19:41, = Larry 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 itsel= f. > >> > >> --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 expresse= d > on Twitter and in the PR: > https://wiki.php.net/rfc/new_without_parentheses#other_syntax_ideas > > -- > > Valentin > > I suspect this will break (badly written) reflection in interesting ways: > > https://3v4l.org/mcSNH > > This basically breaks dereferencing order of operations and makes it > inconsistent. > > Robert Landers > Software Engineer > Utrecht NL > I think these scenarios are all covered in the RFC under "This RFC still does not allow to omit parentheses around the new expression without constructor arguments' parentheses, because in some cases this leads to an ambiguity" --000000000000b0b2790616c304da Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, Apr 23, 2024 at 1:20=E2=80=AF= PM Robert Landers <landers.r= obert@gmail.com> wrote:
On Tue, Apr 23, 2024 at 11:10=E2=80=AFAM Valentin Udaltsov <udalts= ov.valentin@gmail.com> wrote:
>
> =D0=B2=D1=82, 9 =D0=B0=D0=BF=D1=80. 2024=E2=80=AF=D0=B3. =D0=B2 19:41,= Larry Garfield <larry@garfieldtech.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 allo= ws 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:<= br> >> >
>> > ```php
>> >
>> > class MyClass
>> >
>> > {
>> >
>> >=C2=A0 =C2=A0 =C2=A0const CONSTANT =3D 'constant';
>> >
>> >=C2=A0 =C2=A0 =C2=A0public static $staticProperty =3D 'sta= ticProperty';
>> >
>> >=C2=A0 =C2=A0 =C2=A0public static function staticMethod(): str= ing { return 'staticMethod'; }
>> >
>> >=C2=A0 =C2=A0 =C2=A0public $property =3D 'property'; >> >
>> >=C2=A0 =C2=A0 =C2=A0public function method(): string { return = 'method'; }
>> >
>> >=C2=A0 =C2=A0 =C2=A0public function __invoke(): string { retur= n '__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 // st= ring(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-sr= c/pull/13029
>>
>> I always thought there was some technical parser reason why this w= asn'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 chan= ge 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 exp= ressed on Twitter and in the PR: = https://wiki.php.net/rfc/new_without_parentheses#other_syntax_ideas
> --
> Valentin

I suspect this will break (badly written) reflection in interesting ways:
htt= ps://3v4l.org/mcSNH

This basically breaks dereferencing order of operations and makes it
inconsistent.

Robert Landers
Software Engineer
Utrecht NL

I think these scenarios are = all covered in the RFC under "This RFC still does not allow to omit pa= rentheses around the new expression without constructor arguments' pare= ntheses, because in some cases this leads to an ambiguity"=C2=A0
=
--000000000000b0b2790616c304da--