On Thu, 25 Jul 2019 at 14:32, Nikita Popov <nikita....@gmail.com> wrote:
> On Wed, Dec 6, 2017 at 8:49 PM Nikita Popov <nikita....@gmail.com> wrote: > > > 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. > > > > Regards, > > Nikita > > > > I've rebased and finished the implementation for this and would like to > move forward with this RFC. > > I think it can either go forward as-is, in that it constitutes the first > step towards bringing sanity to by-reference passing in the long term. Or I > could first try to push through > https://wiki.php.net/rfc/namespace_scoped_declares or some variant thereof > so that call-site reference passing annotations can be made required on a > per-library/project basis. > > As most of the feedback here has been on whether this is really worthwhile > if it's only optional, I guess the second option would be preferred? > > Nikita > I think this can go as-is and a namespace scoped declare (or something similar) could always be added after the fact to make it required to use via a declare statement. Small semi-related tangent but maybe in conjunction to the strict comparison RFC and making it mandatory to use '&' at the call site via some way, we could have some "meta" declare statement which automatically would enable strict types, mark reference at call site and the strict comparison. Just an idea which I'm not sure is that wise. Best regards George P. Banyard