Re: [RFC] Explicit call-site send-by-ref syntax
| From: | Sara Golemon | Date: | Wed, 06 Dec 2017 21:11:51 +0000 |
| Subject: | Re: [RFC] Explicit call-site send-by-ref syntax | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-101256@lists.php.net to get a copy of this message | ||
On Wed, Dec 6, 2017 at 2:49 PM, Nikita Popov <nikita.ppv@gmail.com> wrote:
> 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.
>
The way I understand this, it only provides a readability hint for the
human, yes? As far as the compiler is concerned, you're either
confirming what it already knows, or it's throwing an error because
what you think will be pass-by-ref, won't be.
I'm not strictly against it in terms of helping readability for
humans, but that kind of information can also live in a docblock with
nearly the same force and effect (modulo the warning when the hint is
wrong).
-Sara