Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123540 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 ED8D91A009C for ; Fri, 7 Jun 2024 16:30:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717777917; bh=rdOnNvnStbRfAEMoUAgnn/D8s2vRDQ945fXuB0uvIiA=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=Y/3Wfd4k1RjBMMupImvxK7IHkY0tUeU9UpN+b5a22IJ9Qj2E4/aaLgtBRWZtPZ6zr KExmN9kZTjB7vWMm3cpPWin/1bfRjkuU6rBwZLRPGudFoLTyyeqJxohaU2CUZDvluN YbK8uZBP3JbEukYQtFinU92it81wigSAz8BE9j4p9yYSXJMYzcz7pkubD/xdKTfmu+ iFKc14INqlmWX8YKJBehLqpw0FT2YJv75O2/0Aftt66nRN2JYUArfFF5JLcFBrTy8R k2vcV+RGMmaXvfnYuUfft3YxLOkIZwFsbUq35KqIMHec6WQc6kjgh037LDtgpIlJB6 Iyf4xFDet/a4w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 672B4180003 for ; Fri, 7 Jun 2024 16:31:56 +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=1.4 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RDNS_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from nebula.zort.net (unknown [96.241.205.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 7 Jun 2024 16:31:55 +0000 (UTC) Received: from smtpclient.apple (pulsar.zort.net [96.241.205.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by nebula.zort.net (Postfix) with ESMTPSA id 894FF20058608; Fri, 7 Jun 2024 12:30:49 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 nebula.zort.net 894FF20058608 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zort.net; s=zort; t=1717777849; bh=rdOnNvnStbRfAEMoUAgnn/D8s2vRDQ945fXuB0uvIiA=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=DbfnWlliFSWBUGxLKie5sk/Lp6ZlX6hZYQclNR4fkQW4JcnHjgWx/FsCmTdXXPowr X9mFjJTmlPQhLEqua/udLWTRMAIlUYD9t71UxA2HJMA8LUqz45WZfs6oPKKfOXt4cE UV8FGKeNNGlfDnGd5oRnNTRxoMMyMjk6XrPsXbNA= Content-Type: text/plain; charset=utf-8 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: [PHP-DEV] RFC proposal : "new" keyword shorthand In-Reply-To: Date: Fri, 7 Jun 2024 12:30:39 -0400 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <3B435D7E-774A-451E-AE52-768A1DB273D8@zort.net> References: To: =?utf-8?Q?Beno=C3=AEt_Condaminet?= X-Mailer: Apple Mail (2.3774.600.62) From: jbafford@zort.net (John Bafford) Hi Beno=C3=AEt, > On Jun 7, 2024, at 12:03, Beno=C3=AEt Condaminet = wrote: >=20 > As a first try, I start updated code to completely make the new = keyword optional, like in Dart language for example, but it require very = big change, with lot of impact (collision with function).=20 >=20 > So here is my proposal :=20 >=20 > Add a "new" shorthand, using the tilde character : "~" > I made a POC, and it works well, declaring a new language token = T_SHORT_NEW that simply reuse ZEND_AST_NEW under the hood. I would point out that ~ is an existing operator, bitwise not. Is there = not the same ambiguity with that as with not having the new keyword at = all? Because PHP has classes and functions in different namespaces = ~SomeClass() looks exactly the same as ~SomeFunction(), and ~$someVar() = would be just as ambiguous. I would prefer to see the new keyword go away as well, but as long as = functions and classes are in separate namespaces, that might be = difficult. -John=