Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113958 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 82351 invoked from network); 5 Apr 2021 17:43:31 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Apr 2021 17:43:31 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BE5091804B3 for ; Mon, 5 Apr 2021 10:42:18 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (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 10:42:18 -0700 (PDT) Received: by mail-qk1-f181.google.com with SMTP id g15so12295338qkl.4 for ; Mon, 05 Apr 2021 10:42:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=UH0UK6fFUnM3vG0eik/wwh2KCilLo+Rsw+0QCD8K7n0=; b=e83sGYcVO99aUDw1Kjsfkg/fGmk2f3fB/hmuSGGKTZZaV5RVR9W+GSSGygb7PpxPQO qP1edfUyztDHlC/0+iLtLpbmoRYMbW/LlWb2cJJDcxuxY1ogEY9da0ajcm3PuyBUn/l6 Aa4mvakGM53gu3mzJt5Q5nfEOqW1NVyYwUEqOSOzAsnxO8r4QWUCE5grlFz6HbFdtAV4 X9QSasTrGwj7ddwyvlGbpMI57SwCiw2CH6FMIC332qjF8Cqx/k+mPSErumpq1pmB7szd F0M06r6+RahrcsnotVXAxJHWzenJxgYCoA8cA00u0FQkMdBcTdxcV32PnMD+ZwBqzb2g TXcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=UH0UK6fFUnM3vG0eik/wwh2KCilLo+Rsw+0QCD8K7n0=; b=TswdcMmYtx+BtxGeANJXhbEb0TKrcz7E9CrJ1M3cTWNkPNr6p3U410LAQawKYPgQhA X2ri5qsRIUgonnS+iDTcXqvAYs/xftc+1iNFdYVkrgnae9CX+guRxRLjMG4GQpEe2Myu nIqwdeH6UKX5JYzVHW/XNcrBNda2x8zj/WFqKOBq19OwVVohlBZ8RpuEVBG0H7xWktJR /jZycr61phNSuBCL4dL/V39V9oak10zhYES+015n6u8wKGvDiZRdiZ7AnxUI53q4ybpx BMDPKCSvgFfAc5XbAwoOJpzZewStncR7LS5D73vHCNJTE1PbEalOUxdXRvoTcY4DARfT 5V+Q== X-Gm-Message-State: AOAM5311zBpqG832b3n87h6+rQOpU0qCzP4NN8R808u0IMFeGolEJQBf uCp0OjJYHr2yXrRqgGoScf/4sA== X-Google-Smtp-Source: ABdhPJz8hXcpomdYQDJ0LrLSH5Cxbnec6ehDWvD0ObbDiEonWVTPmxzuJE8nkbiOCm6zLGv1cd5sdw== X-Received: by 2002:a37:6294:: with SMTP id w142mr25477197qkb.255.1617644536514; Mon, 05 Apr 2021 10:42:16 -0700 (PDT) Received: from [192.168.1.239] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id u12sm13694963qkk.129.2021.04.05.10.42.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Apr 2021 10:42:16 -0700 (PDT) Message-ID: <55DEACD7-E0E8-45AD-84F2-A98D8AEEDC4D@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_CBB39829-FA18-4936-B0DF-58D7729A7006" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Date: Mon, 5 Apr 2021 13:42:15 -0400 In-Reply-To: Cc: PHP internals To: Ben Ramsey References: <0b8301d72a3a$71045ca0$530d15e0$@webkr.de> X-Mailer: Apple Mail (2.3608.120.23.2.4) Subject: Re: [PHP-DEV] Raising the precedence of the new operator From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_CBB39829-FA18-4936-B0DF-58D7729A7006 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Apr 5, 2021, at 12:47 PM, Ben Ramsey wrote: >=20 >> On Apr 5, 2021, at 11:40, Andr=C3=A9 H=C3=A4nsel = wrote: >>=20 >> I was wondering... PHP is the only language I know of where you have = to >> write `(new Foo())->bar()` instead of >> `new Foo()->bar()`. This is particularly apparent with the builder = pattern: >>=20 >> $developer->drink((new Coffee())->withCream()->withSugar()); >> $logger->log((new LogMessage())->withMessage('Coffee was drunk')); >>=20 >> 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". >>=20 >> It's currently a syntax error, so allowing it would be automatically >> compatible. >>=20 >> Has this ever been discussed before? >=20 >=20 > Mike Schinkel and I recently discussed this off-list. Mike, now=E2=80=99= s 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()`. > My $0.02 is that this is unnecessary, but I can see how others might > want it to avoid parenthesis soup. Yes, off list Ben said he did not see the need for it, so I did not = bring it up on the list. =20 But now since he has invited me to... :-) If we had such syntax then that would also Andre and others to use (and = reduce the necessity of needing so many parens: Foo::new()->bar() Thoughts? -Mike= --Apple-Mail=_CBB39829-FA18-4936-B0DF-58D7729A7006--