4 ms·
> Eliminating references. PHP references have unusual semantics, where the function specifies the binding of parameters with no indication at the callsite. I f
by pbiggar 9y ago
> Eliminating references. PHP references have unusual semantics, where the function specifies the binding of parameters with no indication at the callsite.
I feel like I called this one in https://circleci.com/blog/critiquing-facebooks-new-php-spec https://circleci.com/blog/critiquing-facebooks-new-php-spec:
> This is interesting because they’re changing the definition of the language through a sort of back-channel. They’re allowing breaking changes by effectively deciding that other implementation choices are equally valid.
> I’ll give you an example, which I’ll get into more below. There’s a little known bug in the Zend engine around copying arrays that contain references. IBM wrote a paper about this bug in 2009. Basically, this bug was necessary in Zend to make copying arrays fast, and IBM figured out a way to do it in a way that was actually correct, for only a 10% performance penalty.
- fredemmott 9y agoYou'll also see a few of these on http://php.net/manual/en/migration70.incompatible.php http://php.net/manual/en/migration70.incompatible.php :p
- smsm42 9y agoI get why they want to get rid of references. If I would be designing PHP from scratch, that's probably the first thing I'd do - most hard to fix bugs in the engine and most security woes of features such as unserialize() stem from references. Unfortunately, TONS of code uses them, and there are some data structure things that would not work without it unless alternative solution is provided. So it could not happen in PHP. But it'd be interesting to see how it works for Hack.
- fredemmott 9y agowe're currently leaning towards out/inout parameters, with copy semantics, not byref (and in most cases, we'll probably be able to optimize away the copy); not certain yet though.
- smsm42 9y agoWould be nice to hear what comes out of it and how it works!