Re: [PHP-DEV] C++-like function-try-block proposal

  101170
November 27, 2017 18:41 enclaved@Safe-mail.net ("Alexei Gerasimov")
> > Since PHP is partially influenced by C++, I believe this syntax would be > > a meaningful step in making PHP a little bit more intuitively compatible > > with C++ practices, which may prove useful for people who come to PHP from > > the C++ world (such as myself.) The expected benefit is PHP becomes yet > > more familiar and comfortable for C++ programmers. > > > I'm not sure this statement is entirely accurate. PHP's fundamental > inspirations come from perl and C. It's OOP layer was inspired in > part from C++, but also from Java.
Oh, I didn't mean to single C++ out, hence "partially". When I started with PHP OOP not too long ago, I kinda expected that function-try-block construct to work, for no real reason other than a hunch, and it didn't. So after taking a look at the parser, I figured it wouldn't be a big deal to add it just as syntactic sugar (Nikita pointed it out correctly that in C++ it was introduced for the purpose of wrapping around initalizer lists.) After all it'd cost us just one additional level of yacc grammar, i.e. nothing to worry about performance-wise. I could try to come up with a better and more realistic use case example for it if I am ever allowed to make an actual RFC out of it. But still, perhaps my best argument is that it is very cheap to implement, and may potentially make code look neater. -Alexei