Hi Benoît, > On Jun 7, 2024, at 12:03, Benoît Condaminet <condaminet.ben...@gmail.com> > wrote: > > 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). > > So here is my proposal : > > 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