On Wed, Dec 6, 2017 at 12: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.

I think we ought to commit to requiring the ampersand at the call site
some point in the future. As others have noted it provides little
benefit at the call site if it is not required.

However, there is an area where this does provide value that others
have not yet mentioned or thought of: `callable` parameters.

    public function apply(callable $f) {
        return $f(&$this->data);
    }

This requires the callable to accept the argument by reference,
something we cannot currently require. Of course this is rarely
needed; I am merely pointing out this feature is more than a syntactic
hint to humans.

Based on the current discussion I would vote yes on this RFC, despite
the concerns raised by others.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to