Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113969 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 8687 invoked from network); 5 Apr 2021 20:52:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Apr 2021 20:52:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BDF9D1804B3 for ; Mon, 5 Apr 2021 13:51:48 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) (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, 5 Apr 2021 13:51:48 -0700 (PDT) Received: by mail-il1-f174.google.com with SMTP id n4so4395122ili.8 for ; Mon, 05 Apr 2021 13:51:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DpeNYNkVJerdmegP5i23Ooi5hoSZJg/Zt6Mqlx0rWPw=; b=kuSppOMDIuQ71VDGKoDCBUTXpx+R8lo5KAXLEukDLeSbenrxxjqtxMCOnP8zHyHv3n v7002sfCyOd7+dCIb15u2DT786Asyzkkv8zCzrhxvhlnZHpf9FrogLrEx2zQWMCFxRJk UalXg5ZS73Ijc+s9yStb/+v7C5yXYE1fuPKJq1o6lGIgCS0FDgewhmpc/KmQVyLTRqPW 8uByr602ITgAhjq4KPB0BOYhM06wnVKPVlo51Zcp0GaQj/Q1FkVkJCl0XkNPx42g5tzd jCDWEV4yp2hsF1uKCiNlQ+8Yp0ZT67g1aHjMevLZCxsDLDYvIMrTKwAr6oZSXqWhZWF3 kjLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DpeNYNkVJerdmegP5i23Ooi5hoSZJg/Zt6Mqlx0rWPw=; b=fHY0chHtEIq2a6XMfctYH51D0SXTxYngkOhLDtrrxqUrAzdT/GBVs+KJgKG3IdyD5E z8heHcAlQdWK0P4JfrndDjz/fZrDdPftlBpJ1IEAYtFtAZVOZOjBcP3vN/UZrC/XvE4B RBhHqzLzi+IUXAtSTjlRE18hxJ6GRO4ilr3eeWA7HdFQA489q9YTquDXmIXjUaK1c/9/ HvEvGrT7y1fVLOcsQMDJzlhBadd0rGEaLUuaaJOlYpbz8ooaC//KaamSjxMdGQjkL9iH +i9NP+BDhYnmdRXZbfOyhiOfvgWSmR86KjJjKKpzUVFh8pb3dQDIQndZBuQwO3EykTwx BWUA== X-Gm-Message-State: AOAM531mMDLV/BiXlRocxgW2gzrUTQaA76ZukOx+p6uS7H+DZpdnmxEj tAwTXgs4AM9UVy/yN89dCHboxtrDkEmMHvrcS70= X-Google-Smtp-Source: ABdhPJxbwhJPRl2nblhvf7ItxzeTNIsJj+pkspdh6I9JlKj22NiYKaQXIUPmRK9KNPMn5e0dyaKoWk21YrK2dHza0aI= X-Received: by 2002:a92:8752:: with SMTP id d18mr20354442ilm.283.1617655905203; Mon, 05 Apr 2021 13:51:45 -0700 (PDT) MIME-Version: 1.0 References: <0b8301d72a3a$71045ca0$530d15e0$@webkr.de> <55DEACD7-E0E8-45AD-84F2-A98D8AEEDC4D@newclarity.net> In-Reply-To: <55DEACD7-E0E8-45AD-84F2-A98D8AEEDC4D@newclarity.net> Date: Mon, 5 Apr 2021 22:51:33 +0200 Message-ID: To: Mike Schinkel Cc: Ben Ramsey , PHP internals Content-Type: multipart/alternative; boundary="000000000000993c5d05bf3fdd73" Subject: Re: [PHP-DEV] Raising the precedence of the new operator From: ocramius@gmail.com (Marco Pivetta) --000000000000993c5d05bf3fdd73 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Apr 5, 2021, 19:42 Mike Schinkel wrote: > > > On Apr 5, 2021, at 12:47 PM, Ben Ramsey wrote: > > > >> On Apr 5, 2021, at 11:40, Andr=C3=A9 H=C3=A4nsel wrot= e: > >> > >> I was wondering... PHP is the only language I know of where you have t= o > >> write `(new Foo())->bar()` instead of > >> `new Foo()->bar()`. This is particularly apparent with the builder > pattern: > >> > >> $developer->drink((new Coffee())->withCream()->withSugar()); > >> $logger->log((new LogMessage())->withMessage('Coffee was drunk')); > >> > >> Since `new Foo()->bar()` cannot (and probably should not) be used to > >> "dynamically instantiate a new thing of the class > >> name returned by function Foo()", it seems like it would be no problem > to > >> change the precedence rules so that > >> `new Foo()->bar()` means "instantiate a new Foo and call bar() on it". > >> > >> It's currently a syntax error, so allowing it would be automatically > >> compatible. > >> > >> Has this ever been discussed before? > > > > > > Mike Schinkel and I recently discussed this off-list. Mike, now=E2=80= =99s your > > time to chime in with your ideas on this. :-) > > Thanks for the invite. > > I had asked Ben what he thought about allowing the following syntax as a > synonym for `new Foo()`: > > Foo::new() > > That would be backward compatible because you currently cannot have a > method named `new()`. > I have static ctors named `new` in multiple codebases: https://3v4l.org/FudWpk > --000000000000993c5d05bf3fdd73--