Re: Re: [RFC] Explicit call-site send-by-ref syntax
| From: | Stanislav Malyshev | Date: | Sun, 28 Jul 2019 02:47:35 +0000 |
| Subject: | Re: Re: [RFC] Explicit call-site send-by-ref syntax | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-106304@lists.php.net to get a copy of this message | ||
Hi!
> I think nowadays it is well known that by-reference passing is to be
> avoided and I don't see it particularly commonly in user code. By-reference
I don't think it's true. It depends on the style of coding, of course,
but there are many situations where the most convenient solution is
by-ref passing, mostly when single function can change more than one
thing. Of course there are ways around it, but they are less convenient
and less intuitive.
Additionally, if you want a function to do some mutation with arrays,
there's only two ways of doing it - either returning the resulting array
(which can double the data) or pass by-ref. Again, there are ways around
it, but again they are less convenient.
And, if your own argument recognizes internal functions have legitimate
reasons to use references, the same comes for user functions too - they
could implement similar functionality.
--
Stas Malyshev
smalyshev@gmail.com