# [RFC] Explicit call-site send-by-ref syntax

- Thread: https://externals.io/message/101254
- Original archive: https://news-web.php.net/php.internals/101254
- Started by Nikita Popov on 2017-12-06T19:49:03+00:00
- Messages: 72
- RFC: Explicit call-site pass-by-reference (Inactive) — https://externals.io/rfc/explicit_send_by_ref.md
- Page 1 of 3: messages 1 to 25 (25 per page, add `?page=N` to the URL)
- Next page: https://externals.io/message/101254.md?page=2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #101254 — Nikita Popov — 2017-12-06T19:49:03+00:00

URL: https://externals.io/message/101254#101254

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

---

## #101255 — lists@rhsoft.net — 2017-12-06T20:08:13+00:00

URL: https://externals.io/message/101254#101255 · In reply to: #101254

Am 06.12.2017 um 20:49 schrieb Nikita Popov:
> 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

IMHO a bad idea after "PHP Fatal error: Call-time pass-by-reference has 
been removed" not that long ago which was exactly the same syntax

https://stackoverflow.com/questions/8971261/php-5-4-call-time-pass-by-reference-easy-fix-available

https://stackoverflow.com/questions/18046846/why-is-function-call-by-reference-in-php-deprecated

---

## #101256 — Sara Golemon — 2017-12-06T21:11:51+00:00

URL: https://externals.io/message/101254#101256 · In reply to: #101254

> 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

---

## #101257 — Sara Golemon — 2017-12-06T21:14:31+00:00

URL: https://externals.io/message/101254#101257 · In reply to: #101256

>... 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).
>
Sorry, ignore that last statement. I've got a weird headache going on atm.

Still neutral on it either way.  Yay for readability by humans, I guess.

-Sara

---

## #101258 — Rowan Collins — 2017-12-06T21:31:54+00:00

URL: https://externals.io/message/101254#101258 · In reply to: #101254

> 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


Hi Nikita,

I approve of the aims of this proposal, but I do wonder if it would be a 
bit awkward to reuse the syntax which people had to spend so much effort 
removing in PHP 5.4 (you refer to it as a PHP 4 feature, but for many 
people it's a much more recent memory). Aside from the frustration of 
"why didn't we allow it in these cases all along", I can see people 
being confused if it went from OK to fatal error to encouraged and maybe 
even mandatory.

Your future scope section mentions having more explicit "out" and 
"inout" annotations; perhaps it would be better to skip ahead to these, 
with new syntax, and more immediate benefits all round. Is there a 
reason we can't do this right now?

I imagine these working like the & annotation, with the following extra 
rules:

1) Parameters marked "out" or "inout" in function definitions MUST also 
be marked "out" or "inout" in calls to that function.
2) Parameters marked "&" in function definitions MAY be marked with 
"out" or "inout" in calls to that function.
3) A variable passed to an "inout" parameter would raise a notice if it 
was not defined before use, since it should have a value for the "in" part.
4) A variable passed to an "out" parameter would NOT raise such a 
notice, since the function call would be a valid initialisation.
5) An already-initialised variable passed to an "out" parameter would be 
set to null before calling the function. If the function never assigned 
to it, it would remain null in the calling scope.

Rule 2 allows for better interoperability between old and new code, and 
I am imagining it also applying to core functions, so that this would 
work without pre-initialising $matches: preg_match($pattern, $string, 
out $matches);

I'm not sure how reference-returning functions fit into this picture, 
and there are probably other kinks to iron out, but it seems like it 
would have a lot more benefits overall.

Regards,

-- 
Rowan Collins
[IMSoP]

---

## #101259 — David Walker — 2017-12-06T21:41:28+00:00

URL: https://externals.io/message/101254#101259 · In reply to: #101258

On Wed, Dec 6, 2017 at 2:32 PM Rowan Collins <rowan.collins@gmail.com>
wrote:

> 
> > […]
>
>
> Hi Nikita,
>
> I approve of the aims of this proposal, but I do wonder if it would be a
> bit awkward to reuse the syntax which people had to spend so much effort
> removing in PHP 5.4 (you refer to it as a PHP 4 feature, but for many
> people it's a much more recent memory). Aside from the frustration of
> "why didn't we allow it in these cases all along", I can see people
> being confused if it went from OK to fatal error to encouraged and maybe
> even mandatory.
>
> Your future scope section mentions having more explicit "out" and
> "inout" annotations; perhaps it would be better to skip ahead to these,
> with new syntax, and more immediate benefits all round. Is there a
> reason we can't do this right now?
>
> I imagine these working like the & annotation, with the following extra
> rules:
>
> 1) Parameters marked "out" or "inout" in function definitions MUST also
> be marked "out" or "inout" in calls to that function.
> 2) Parameters marked "&" in function definitions MAY be marked with
> "out" or "inout" in calls to that function.
> 3) A variable passed to an "inout" parameter would raise a notice if it
> was not defined before use, since it should have a value for the "in" part.
> 4) A variable passed to an "out" parameter would NOT raise such a
> notice, since the function call would be a valid initialisation.
> 5) An already-initialised variable passed to an "out" parameter would be
> set to null before calling the function. If the function never assigned
> to it, it would remain null in the calling scope.
>
> Rule 2 allows for better interoperability between old and new code, and
> I am imagining it also applying to core functions, so that this would
> work without pre-initialising $matches: preg_match($pattern, $string,
> out $matches);
>
> I'm not sure how reference-returning functions fit into this picture,
> and there are probably other kinks to iron out, but it seems like it
> would have a lot more benefits overall.
>
> Regards,


Hi Nikita,

I'd be more hesitant about seeing this syntax re-introdouced.  Having
recently been through the process of spending days to remove all the
call-time by-reference fatals.  Especially when the syntax proposed is
generally ignored (excepting in the has &, but declaration doesn't).

I do like the C-esque feel of having the declaration require a reference,
and the call-side provide the reference, but the RFC lacks the warning
where the declaration has reference, but call-side lacks it.  However,
adding this warning would probably anger everyone who did spend the time to
remove all the call-time references only to now add them back in.

I'd be with Rowan here.  If the language is going to re-introduce old
syntax as purely a visual aid, it would probably behoove us to actually
look at the in/inout/out parameter types.  I would be way more excited to
see that play out, than having call-time-reference brought back.

Cheers,
--
Dave

---

## #101260 — Stanislav Malyshev — 2017-12-07T02:04:04+00:00

URL: https://externals.io/message/101254#101260 · In reply to: #101254

Hi!

> 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.

We had usage of this syntax for similar, but different purpose before it
was removed. Reinstating it now would be confusing, and generally not a
good practice - having one syntax mean different things in different PHP
versions is not good.
It is not likely that we'd ever want to make it mandatory, due to the
overwhelming mass of code relying on the current syntax, and without it
instead of making code more clear, it would make it more confusing - if
& means by-ref, does absence of it mean by-value? Nope. So you still
have to check. Unless of course you rework all existing code to add & -
which would be rather hard and will make it incompatible with every
currently supported version of PHP.
All this to achieve no other benefit but a purely cosmetic one which a
good IDE could easily deliver to you for free without changing language
syntax. I do not think it is worth it.

-- 
Stas Malyshev
smalyshev@gmail.com

---

## #101262 — bjorn.x.larsson@telia.com — 2017-12-08T00:38:16+00:00

URL: https://externals.io/message/101254#101262 · In reply to: #101254

Den 2017-12-06 kl. 20:49, skrev Nikita Popov:

> 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 think this proposal has a good point about static analysers,
not just about human readability.

A good static analyser is very helpful for eg migration projects
and if this proposal benefits that, it's a plus. Also using same
syntax for references like in other parts of the language has a
value.

Now expressing the same thing in two different ways, with or
without & is confusing, so I think one needs to think about if
old syntax should be deprecated in 8.0.

Has never used PHP 4, so not confused by old PHP 4 syntax
but I guess for people on this list the percentage is higher...

r//Björn

---

## #101263 — lists@rhsoft.net — 2017-12-08T01:54:16+00:00

URL: https://externals.io/message/101254#101263 · In reply to: #101262

Am 08.12.2017 um 01:38 schrieb Björn Larsson:
> Den 2017-12-06 kl. 20:49, skrev Nikita Popov:
> 
> > […]
> I think this proposal has a good point about static analysers,
> not just about human readability.
> 
> A good static analyser is very helpful for eg migration projects
> and if this proposal benefits that, it's a plus. Also using same
> syntax for references like in other parts of the language has a
> value.
> 
> Now expressing the same thing in two different ways, with or
> without & is confusing, so I think one needs to think about if
> old syntax should be deprecated in 8.0

to get this consistent that would also require change every line of code 
calling core functions like sort instead of sort($array) as sort($array)

i doubt that the benefits could justify the BC break

---

## #101264 — Stephen Reay — 2017-12-08T04:41:46+00:00

URL: https://externals.io/message/101254#101264 · In reply to: #101263

> 
> 
> 
> 
> > […]
> 
> to get this consistent that would also require change every line of code calling core functions like sort instead of sort($array) as sort($array)
> 
> i doubt that the benefits could justify the BC break
> 
> -- 
> 
> 
> 

I think Rowan's suggestion makes a lot of sense. There's zero bc break for existing code, but new/updated code can get the benefits of being specific about how the parameter is used.

I know "references are the wrong tool for any job" is a belief held my some of the community - I'm curious if out/inout parameters solve any of their concerns about references?

Cheers

Stephen

---

## #101266 — me@jhdxr.com — 2017-12-08T07:12:19+00:00

URL: https://externals.io/message/101254#101266 · In reply to: #101264

> > […]
>
>I think Rowan's suggestion makes a lot of sense. There's zero bc break for existing code, but new/updated code can get the benefits of being specific about how the parameter is used.

Agreed, and I think those BC break change will be fine if it targets 8.0. I know people always argue that it's stupid to break the working code, but IMHO it's ok for a major version update with good reason.

---

## #101267 — lists@rhsoft.net — 2017-12-08T10:16:01+00:00

URL: https://externals.io/message/101254#101267 · In reply to: #101264

Am 08.12.2017 um 05:41 schrieb Stephen Reay:
> 
> 
> > […]
> I think Rowan's suggestion makes a lot of sense. There's zero bc break for existing code, but new/updated code can get the benefits of being specific about how the parameter is used.

"Now expressing the same thing in two different ways, with or without & 
is confusing, so I think one needs to think about if old syntax should 
be deprecated in 8.0" would be a massive BC break

and it's much bader to use a not so long existed syntax which was now 
changed to a fatal error - just type "php call-by-reference" in google

> I know "references are the wrong tool for any job" is a belief held my some of the community - I'm curious if out/inout parameters solve any of their concerns about references?

now because they are not bad because the syntax, they are bad fopr most 
usecases because you try to be smarter the PHP's copy-on-write but in 
most cases you won't

---

## #101268 — me@jhdxr.com — 2017-12-08T16:36:23+00:00

URL: https://externals.io/message/101254#101268 · In reply to: #101267

>
>and it's much bader to use a not so long existed syntax which was now
>changed to a fatal error - just type "php call-by-reference" in google
>
I know most people of this list using and contributing to PHP for a very long time, but I want to point out that the old "call-time pass-by-reference" was deprecated from php 5.3, which is more than 8 years ago. People with modern framework and tools are not troubled by the old and already removed syntax. The real trouble is I cannot figure out the parameter is passed by reference or value unless I go to the defination of the method.
btw, I really googled "php call-by-reference", the latest page was post on 2012, 5 years ago.



> > […]
>
>now because they are not bad because the syntax, they are bad fopr most
>usecases because you try to be smarter the PHP's copy-on-write but in
>most cases you won't
If you point is pass-by-reference is bad and stupid, then it's off-topic and I suggest you should create a new RFC to abandon this feature. This RFC is aimed at making things more clear for developers and static analyzers.

---

## #101270 — lists@rhsoft.net — 2017-12-08T16:56:32+00:00

URL: https://externals.io/message/101254#101270 · In reply to: #101268

Am 08.12.2017 um 17:36 schrieb CHU Zhaowei:
> 
> > […]
> I know most people of this list using and contributing to PHP for a very 
> long time, but I want to point out that the old "call-time 
> pass-by-reference" was deprecated from php 5.3, which is more than 8 
> years ago

but PHP 5.4 where it changed ot be a fatal error is not that long ago 
and will live many years because it's part of RHEL7

> People with modern framework and tools are not troubled by 
> the old and already removed syntax. The real trouble is I cannot figure 
> out the parameter is passed by reference or value unless I go to the 
> defination of the method.
> btw, I really googled "php call-by-reference", the latest page was post 
> on 2012, 5 years ago.

you can not because people don't use proper comments
myfunction /**&$var*/$x);

> If you point is pass-by-reference is bad and stupid, then it's off-topic 
> and I suggest you should create a new RFC to abandon this feature. This 
> RFC is aimed at making things more clear for developers and static 
> analyzers

my main point was that if you don't make it mandatory it's worth nothing 
and if you make it mandatory you need to bew aware that this not only 
affects in PHP written function but also all calls to internal functions 
which work wit references like `sort()` and so *a lot* of code written in 
PHP needs to be touched

FRANKLY:
if you re-use the syntax and make it mandatoty it's terrible while adopt 
code because all your existing code won't work with the next PHP version 
and every adopted line no longer works with the current version because 
it throws fatal errors

you also need to consider adoption of a future PHP version which likely 
get a heavy impact with syntax changes where the same code has two 
different meanings while both throw fatal errors in a older or in the 
next one
________________________

to make things clearer for developers comments where invented - see 
above - and that most php developers don't wirte well commented and 
readable code is a completly different story

static analyzers - well, i need yet to see one really useable for PHP 
code, but that#s also a different story

the real issue:
if the long plan is to make the call syntax mandarory it still should 
not re-use a syntax which was deprecated and removed years ago because 
the fact you will find tons of stuff refer to the old one

it should really use something else and no re-use

---

## #101271 — Stephen Reay — 2017-12-08T17:55:02+00:00

URL: https://externals.io/message/101254#101271 · In reply to: #101267

> 
> 
> "Now expressing the same thing in two different ways, with or without & is confusing, so I think one needs to think about if old syntax should be deprecated in 8.0" would be a massive BC break

That wasn’t in Rowans suggestion, it was in Björn’s response to the original message. You’re either not reading who wrote what before you reply, or you’re deliberately trying to imply a person has advocated for something they never even mentioned.

Even *if* the consensus was to drop support for & references in php8 - thats a major new version, with AFAIK, literally no planned ETA, of any kind.

---

## #101272 — lists@rhsoft.net — 2017-12-09T02:15:12+00:00

URL: https://externals.io/message/101254#101272 · In reply to: #101271

Am 08.12.2017 um 18:55 schrieb Stephen Reay:
> > […]
> 
> That wasn’t in Rowans suggestion, it was in Björn’s response to the 
> original message. You’re either not reading who wrote what before you 
> reply, or you’re deliberately trying to imply a person has advocated for 
> something they never even mentioned.

i responded to Björn's response and when someone than quotes me and 
refer to a side thread i am really not guilty

> Even *if* the consensus was to drop support for & references in php8 - 
> thats a major new version, with AFAIK, literally no planned ETA, of any 
> kind

besides that's not the topic at all and i just responded to "If you 
point is pass-by-reference is bad and stupid, then it's off-topic and I 
suggest you should create a new RFC to abandon this feature"

however, "that's a major new version" is completly irrelevant in this 
point of time - what is relevant to think about the outcome of whatever 
is suggested *long before* something is even seriously considered to 
make things right - with the least possible BC break unless it is 
justified by a major benefit which makes the break worth

that's somehow learning from past mistakes and avoid to repeat them in 
similar changes - if such discussions would have happened always before 
consider implementations we would not sit here with similar functions 
but reverse parameter order and other such "nice" things which are ugly 
but fix them now would introduce a lot of more troubles than it solves

---

## #101293 — johannes@schlueters.de — 2017-12-10T13:12:56+00:00

URL: https://externals.io/message/101254#101293 · In reply to: #101254

Hi,


> 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
> 

I would rather discourage usage of references. Since PHP 7 the cost of
breaking cow isn't as expensive anymore, but receiving values by value
and returning by value is more idiomatic imo. Using objects can be more
efficient.

johannes

---

## #101295 — Andreas Hennings — 2017-12-10T21:41:08+00:00

URL: https://externals.io/message/101254#101295 · In reply to: #101260

>
> All this to achieve no other benefit but a purely cosmetic one which a
> good IDE could easily deliver to you for free without changing language
> syntax. I do not think it is worth it.
>

I agree with Stanislav, this should be the IDE's job.

PhpStorm can already show parameter name hints in function calls. It could
easily add a feature to show if a parameter is by-reference.
In fact I will request this as we speak :)

---

## #101296 — Andreas Hennings — 2017-12-10T21:43:16+00:00

URL: https://externals.io/message/101254#101296 · In reply to: #101295

Oh wow, feature request already exists, with a link to this thread.



>
>
> On 7 December 2017 at 03:04, Stanislav Malyshev <smalyshev@gmail.com>
> wrote:
> > […]
>
> I agree with Stanislav, this should be the IDE's job.
>
> PhpStorm can already show parameter name hints in function calls. It could
> easily add a feature to show if a parameter is by-reference.
> In fact I will request this as we speak :)

---

## #101300 — Levi Morrison — 2017-12-11T02:29:51+00:00

URL: https://externals.io/message/101254#101300 · In reply to: #101254

> 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.

---

## #101328 — Stanislav Malyshev — 2017-12-12T06:38:54+00:00

URL: https://externals.io/message/101254#101328 · In reply to: #101293

Hi!

> I would rather discourage usage of references. Since PHP 7 the cost of
> breaking cow isn't as expensive anymore, but receiving values by value
> and returning by value is more idiomatic imo. Using objects can be more
> efficient.

Objects are kind of overkill when you just need a modifyable array. And
copying an array when you just need to add one value to a K-size array
is still not a good idea for many apps. O(n) vs O(n^2) still matters.
One should definitely be careful not to overuse refs, but there are
still valid cases for using them.

-- 
Stas Malyshev
smalyshev@gmail.com

---

## #101330 — johannes@schlueters.de — 2017-12-12T07:43:22+00:00

URL: https://externals.io/message/101254#101330 · In reply to: #101328

>Hi!
>
> > […]
>of
> > […]
>value
> > […]
>more
> > […]
>
>Objects are kind of overkill when you just need a modifyable array. And
>copying an array when you just need to add one value to a K-size array
>is still not a good idea for many apps. O(n) vs O(n^2) still matters.
>One should definitely be careful not to overuse refs, but there are
>still valid cases for using them.

The issue, as you well know, is that references disable copy-on-write. Thus assume you have code like this:

function with_ref(&$a) {
   count ($a);
}

function no_ref($a) {
  count($a);
}

The count in with_ref() will copy the array, while no_ref() can use copy on write and won't actually copy.

johannes

---

## #101332 — Stanislav Malyshev — 2017-12-12T07:51:42+00:00

URL: https://externals.io/message/101254#101332 · In reply to: #101330

Hi!

> The issue, as you well know, is that references disable copy-on-write. Thus assume you have code like this:
> 
> function with_ref(&$a) {
>    count ($a);
> }
> 
> function no_ref($a) {
>   count($a);
> }
> 
> The count in with_ref() will copy the array, while no_ref() can use copy on write and won't actually copy.

Yes, this is an issue, and it'd be good to find a way to solve it. At
least for `count()` and other "pure" (however pure can it be in PHP)
functions it seems possible. But do not think "not using references
ever" qualifies as a solution :)

-- 
Stas Malyshev
smalyshev@gmail.com

---

## #101333 — johannes@schlueters.de — 2017-12-12T08:16:08+00:00

URL: https://externals.io/message/101254#101333 · In reply to: #101332

>Hi!
>
> > […]
>copy-on-write. Thus assume you have code like this:
> > […]
>copy on write and won't actually copy.
>
>Yes, this is an issue, and it'd be good to find a way to solve it. At
>least for `count()` and other "pure" (however pure can it be in PHP)
>functions it seems possible. But do not think "not using references
>ever" qualifies as a solution :)

For this case there is a good solution: Let the engine be smart and pass by value :-D

And yes there are a few cases where references might be better: Graph like structures (while I'd claim objects are nicer, but that's subjective), capturing by-ref in closures (`use` clause, while many times an object to hold state can be, subjectively, better, but sometimes you just need a counter or such) and returning error codes by-ref (if objects or exceptions aren't better, this most often is more low-level stuff, i.e. in `json_decode()` I'd see benefits over json_error_last())

Some years back I spent quite some time with different cases almost always removing the references gave faster and clearer code (while this proposal to add & to the call sign takes away some wtf) not only in my opinion, but also the respective maintainers. Of course with PHP 7 the maths changed a bit, but fundamentally I stand by my opinion.

johannes

---

## #101335 — Nikita Popov — 2017-12-12T13:45:23+00:00

URL: https://externals.io/message/101254#101335 · In reply to: #101330

On Tue, Dec 12, 2017 at 8:43 AM, Johannes Schlüter <johannes@schlueters.de>
wrote:

>
>
> On December 12, 2017 7:38:54 AM GMT+01:00, Stanislav Malyshev <
> smalyshev@gmail.com> wrote:
> > […]
>
> The issue, as you well know, is that references disable copy-on-write.
> Thus assume you have code like this:
>
> function with_ref(&$a) {
>    count ($a);
> }
>
> function no_ref($a) {
>   count($a);
> }
>
> The count in with_ref() will copy the array, while no_ref() can use copy
> on write and won't actually copy.


This is no longer the case as of PHP 7. PHP 7 can share values between
references and non-references.

Nikita

---

Next page: https://externals.io/message/101254.md?page=2
