Le mer. 6 déc. 2017 à 20:50, Nikita Popov <nikita....@gmail.com> a écrit :
> Hi internals, > > I'd like propose optional support for explicitly marking by-reference > argument passing at the call-site, in addition to the declaration-site: > > https://wiki.php.net/rfc/explicit_send_by_ref > > In short, while currently we have > > function byRef(&$ref) {...} > byRef($var); > > this proposal would also allow > > function byRef(&$ref) {...} > byRef(&$var); > > so that the use of by-reference passing is obvious without having to > consult the function declaration. > I fully support this RFC. I've been caught many times forgetting about the fact some argument was modified by reference. Putting this information on the call side would definitely make code faster to decipher. References are part of the language. The fact that some think they should be avoided is orthogonal to the proposal. It's good to improve them. Also I think enough time has passed since php4's call-by-ref for the syntax to be reused now. I think it's unfair to call the RFC a reminiscent of call-by-ref BTW. About requiring such call-annotations using a "declare" directive it feels like a heated topic. But we don't need it, so let's split it appart. I could very well see userland tools enforce it at the CS-checking level. That would provide 99.999% of the target benefit while saving us some mental health issues and some unneeded technical challenges to solve. My 2 cts, Nicolas