Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113970 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 10015 invoked from network); 5 Apr 2021 20:54:14 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Apr 2021 20:54:14 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1806C1804DC for ; Mon, 5 Apr 2021 13:53:06 -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-f181.google.com (mail-il1-f181.google.com [209.85.166.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 13:53:05 -0700 (PDT) Received: by mail-il1-f181.google.com with SMTP id 6so1550030ilt.9 for ; Mon, 05 Apr 2021 13:53:05 -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=57fN/j5PxcouT3imgGWezkevsK6TqkPX6dLXwiuclIY=; b=epUQP9iWKg6FHaCvGGDQ+pJeCmSn2e/pCiI/vVxgg0QjvO/F5vsKqpQHQFPv2SBBIa QFaRgTlj0q3sH/Hs7yPlMGANmIpa5IUCVgG3n4eZFVRDXW2UJKxgWRjkwhES+DiDZkJQ m945vUi3fjZvUqlaLFA9hnohKcWmFrVM9bpyqL2PAL62eI3qqsjHfuZ7Vi8Czx616WaA QSZTf5ZCh9fOXAb1pvGISdeKh3NC6lx3D/bR+KUCO5NRRfSjtBs7fAJvX7vPdP6xZJuQ cWg6nLy4y4flIqw/kBvnM2ERQN1wJEArwkzC1zEjE/LQpwk1uHibWWM7lS7r1qWpT+cx GQgA== 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=57fN/j5PxcouT3imgGWezkevsK6TqkPX6dLXwiuclIY=; b=RaxDeX0NxD/82DYt15yxlku923380/e+GonqwfP+qpn2i7zy7jjAt4Ivpnmqf9SXvu FCZa4TWWhVS+Ia0cEjnrPB1DRaxBsQ1snaDqowM+Gl+LXUy3RvHbjx9DQjR9tNjtGWKD kV0+flk6JJh0akUEAX2vkww9nzqTzQ2eQPYsTHgB4O5MB2VJnHZoMvgeVH/WNS3k6nlQ dThRdLnzkCnuxJC7WG8x/x/vhBDuBtAcXltvX1kq9hywsUGTWBY7ypufvydqQCiyhTVn 7QX3cHHpVjBc8mItfxcXOEug3c8WkwQLFxlZDOU9C4D6/ZAGv578ySlH5n8udObimuB3 mSfQ== X-Gm-Message-State: AOAM533tzoAzoIgNA9ik/+sXG0oUBRxcapoLz8OvSqRRh83HrtlJpDlc g0i9VII6NTDS8uVnMbnbbckqkygOvO2XLQS2YPF5KCqf/JY= X-Google-Smtp-Source: ABdhPJzIK1lnII1QYAENuIXaL2+PERSuddNlKjFmbAx2HFMSgbJLuKJQasQaW6PBVwzN2hEljAPucFuLmyIhwHMrmb0= X-Received: by 2002:a05:6e02:e14:: with SMTP id a20mr3527644ilk.282.1617655984922; Mon, 05 Apr 2021 13:53:04 -0700 (PDT) MIME-Version: 1.0 References: <0b8301d72a3a$71045ca0$530d15e0$@webkr.de> <55DEACD7-E0E8-45AD-84F2-A98D8AEEDC4D@newclarity.net> In-Reply-To: Date: Mon, 5 Apr 2021 22:52:53 +0200 Message-ID: To: Mike Schinkel Cc: Ben Ramsey , PHP internals Content-Type: multipart/alternative; boundary="00000000000059a30c05bf3fe28a" Subject: Re: [PHP-DEV] Raising the precedence of the new operator From: ocramius@gmail.com (Marco Pivetta) --00000000000059a30c05bf3fe28a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Apr 5, 2021, 22:51 Marco Pivetta wrote: > > > 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 wro= te: >> >> >> >> 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: >> >> >> >> $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 proble= m >> 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 > > Sorry, mails synchronized now, and I did not realize that you already had a waterfall of responses related to this :| > --00000000000059a30c05bf3fe28a--